X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiPurge.php;h=bb1f3d3bf90d79c842c19d58e447f911967df21c;hb=520b167979260edf2cee41842e526ec985c37f92;hp=35f93e076ab0b6d9fce4db02adf9e917a70fafa8;hpb=fb291fe9d31cba69ae8cebeb5ba04f76f35d7816;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiPurge.php b/includes/api/ApiPurge.php index 35f93e076a..bb1f3d3bf9 100644 --- a/includes/api/ApiPurge.php +++ b/includes/api/ApiPurge.php @@ -1,12 +1,5 @@ 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 ) { - 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; @@ -137,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 ); }