X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FrefreshLinks.php;h=c1170fc0266c3603ba175e94f34b57f7c8b5450d;hb=e65f8ac5110804067366f9f239c13f4f29b66c3d;hp=4fab1461d9d5d2befc5fbbc6aab42cecbc989369;hpb=34e956016bb9189af091569946257e5b9b138585;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/refreshLinks.php b/maintenance/refreshLinks.php index 4fab1461d9..c1170fc026 100644 --- a/maintenance/refreshLinks.php +++ b/maintenance/refreshLinks.php @@ -21,6 +21,8 @@ * @ingroup Maintenance */ +use MediaWiki\MediaWikiServices; +use MediaWiki\Revision\RevisionRecord; use Wikimedia\Rdbms\IDatabase; require_once __DIR__ . '/Maintenance.php'; @@ -170,8 +172,8 @@ class RefreshLinks extends Maintenance { } } else { if ( !$end ) { - $maxPage = $dbr->selectField( 'page', 'max(page_id)', false ); - $maxRD = $dbr->selectField( 'redirect', 'max(rd_from)', false ); + $maxPage = $dbr->selectField( 'page', 'max(page_id)', '', __METHOD__ ); + $maxRD = $dbr->selectField( 'redirect', 'max(rd_from)', '', __METHOD__ ); $end = max( $maxPage, $maxRD ); } $this->output( "Refreshing redirects table.\n" ); @@ -230,7 +232,7 @@ class RefreshLinks extends Maintenance { } $rt = null; - $content = $page->getContent( Revision::RAW ); + $content = $page->getContent( RevisionRecord::RAW ); if ( $content !== null ) { $rt = $content->getUltimateRedirectTarget(); } @@ -258,7 +260,7 @@ class RefreshLinks extends Maintenance { public static function fixLinksFromArticle( $id, $ns = false ) { $page = WikiPage::newFromID( $id ); - LinkCache::singleton()->clear(); + MediaWikiServices::getInstance()->getLinkCache()->clear(); if ( $page === null ) { return; @@ -267,17 +269,14 @@ class RefreshLinks extends Maintenance { return; } - $content = $page->getContent( Revision::RAW ); - if ( $content === null ) { - return; - } - - $updates = $content->getSecondaryDataUpdates( - $page->getTitle(), /* $old = */ null, /* $recursive = */ false ); - foreach ( $updates as $update ) { - DeferredUpdates::addUpdate( $update ); - DeferredUpdates::doUpdates(); - } + // Defer updates to post-send but then immediately execute deferred updates; + // this is the simplest way to run all updates immediately (including updates + // scheduled by other updates). + $page->doSecondaryDataUpdates( [ + 'defer' => DeferredUpdates::POSTSEND, + 'recursive' => false, + ] ); + DeferredUpdates::doUpdates(); } /** @@ -489,5 +488,5 @@ class RefreshLinks extends Maintenance { } } -$maintClass = 'RefreshLinks'; +$maintClass = RefreshLinks::class; require_once RUN_MAINTENANCE_IF_MAIN;