From: umherirrender Date: Tue, 19 Jul 2016 16:15:13 +0000 (+0200) Subject: ApiPurge: Do not die on non content pages X-Git-Tag: 1.31.0-rc.0~6335 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=commitdiff_plain;h=815055276a75ff01cf967a478de43f2acf8e6169;p=lhc%2Fweb%2Fwiklou.git ApiPurge: Do not die on non content pages Some pages seems to have page_latest = 0, and therefore no content to linkupdate. To not get a BadMethodCallException (see T140514) there is a null checked needed. Change-Id: I1ebfcf131ad3f59f38ec2583650eba5b43bac999 --- diff --git a/includes/api/ApiPurge.php b/includes/api/ApiPurge.php index 64bb9ba101..822369afbb 100644 --- a/includes/api/ApiPurge.php +++ b/includes/api/ApiPurge.php @@ -68,35 +68,37 @@ class ApiPurge extends ApiBase { # Parse content; note that HTML generation is only needed if we want to cache the result. $content = $page->getContent( Revision::RAW ); - $enableParserCache = $this->getConfig()->get( 'EnableParserCache' ); - $p_result = $content->getParserOutput( - $title, - $page->getLatest(), - $popts, - $enableParserCache - ); - - # Logging to better see expensive usage patterns - if ( $forceRecursiveLinkUpdate ) { - LoggerFactory::getInstance( 'RecursiveLinkPurge' )->info( - "Recursive link purge enqueued for {title}", - [ - 'user' => $this->getUser()->getName(), - 'title' => $title->getPrefixedText() - ] + if ( $content ) { + $enableParserCache = $this->getConfig()->get( 'EnableParserCache' ); + $p_result = $content->getParserOutput( + $title, + $page->getLatest(), + $popts, + $enableParserCache ); - } - - # Update the links tables - $updates = $content->getSecondaryDataUpdates( - $title, null, $forceRecursiveLinkUpdate, $p_result ); - DataUpdate::runUpdates( $updates ); - - $r['linkupdate'] = true; - if ( $enableParserCache ) { - $pcache = ParserCache::singleton(); - $pcache->save( $p_result, $page, $popts ); + # Logging to better see expensive usage patterns + if ( $forceRecursiveLinkUpdate ) { + LoggerFactory::getInstance( 'RecursiveLinkPurge' )->info( + "Recursive link purge enqueued for {title}", + [ + 'user' => $this->getUser()->getName(), + 'title' => $title->getPrefixedText() + ] + ); + } + + # Update the links tables + $updates = $content->getSecondaryDataUpdates( + $title, null, $forceRecursiveLinkUpdate, $p_result ); + DataUpdate::runUpdates( $updates ); + + $r['linkupdate'] = true; + + if ( $enableParserCache ) { + $pcache = ParserCache::singleton(); + $pcache->save( $p_result, $page, $popts ); + } } } else { $error = $this->parseMsg( [ 'actionthrottledtext' ] );