X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiPurge.php;h=bb1f3d3bf90d79c842c19d58e447f911967df21c;hb=5455d4c43122d66e1bc1a62d700684e14f13e557;hp=b7cfc2c6a20b659a3c27700dcef1ba0f1b13c926;hpb=6bd1e23f4a281b05e6c171653a715c394aac36d6;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiPurge.php b/includes/api/ApiPurge.php index b7cfc2c6a2..bb1f3d3bf9 100644 --- a/includes/api/ApiPurge.php +++ b/includes/api/ApiPurge.php @@ -1,5 +1,4 @@ pingLimiter( 'linkpurge' ) ) { - $popts = $page->makeParserOptions( 'canonical' ); - - # Parse content; note that HTML generation is only needed if we want to cache the result. - $content = $page->getContent( Revision::RAW ); - if ( $content ) { - $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() + ] ); - - # 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 ); - foreach ( $updates as $update ) { - $update->setCause( 'api-purge', $this->getUser()->getName() ); - DeferredUpdates::addUpdate( $update, DeferredUpdates::PRESEND ); - } - - $r['linkupdate'] = true; - - if ( $enableParserCache ) { - $pcache = MediaWikiServices::getInstance()->getParserCache(); - $pcache->save( $p_result, $page, $popts ); - } } + + $page->updateParserCache( [ + 'causeAction' => 'api-purge', + 'causeAgent' => $this->getUser()->getName(), + ] ); + $page->doSecondaryDataUpdates( [ + 'recursive' => $forceRecursiveLinkUpdate, + 'causeAction' => 'api-purge', + 'causeAgent' => $this->getUser()->getName(), + 'defer' => DeferredUpdates::PRESEND, + ] ); + $r['linkupdate'] = true; } else { $this->addWarning( 'apierror-ratelimited' ); $forceLinkUpdate = false; @@ -132,7 +114,7 @@ class ApiPurge extends ApiBase { * @return ApiPageSet */ private function getPageSet() { - if ( !isset( $this->mPageSet ) ) { + if ( $this->mPageSet === null ) { $this->mPageSet = new ApiPageSet( $this ); }