X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FupdateSpecialPages.php;h=01aace0738427f45f1e5654347a81638029daeea;hb=56d45558b102349f3480a46819669407aa3be2d6;hp=1c6f9b339dffda4596d687a2c5842ab5f0536eed;hpb=3f59cb9f3a53ad28f8a95fe299c5de6abd24b453;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/updateSpecialPages.php b/maintenance/updateSpecialPages.php index 1c6f9b339d..01aace0738 100644 --- a/maintenance/updateSpecialPages.php +++ b/maintenance/updateSpecialPages.php @@ -24,6 +24,9 @@ require_once __DIR__ . '/Maintenance.php'; +use MediaWiki\MediaWikiServices; +use Wikimedia\Rdbms\DBReplicationWaitError; + /** * Maintenance script to update cached special pages. * @@ -48,7 +51,7 @@ class UpdateSpecialPages extends Maintenance { foreach ( QueryPage::getPages() as $page ) { list( $class, $special ) = $page; - $limit = isset( $page[2] ) ? $page[2] : null; + $limit = $page[2] ?? null; # --list : just show the name of pages if ( $this->hasOption( 'list' ) ) { @@ -81,7 +84,7 @@ class UpdateSpecialPages extends Maintenance { if ( $queryPage->isExpensive() ) { $t1 = microtime( true ); # Do the query - $num = $queryPage->recache( $limit === null ? $wgQueryCacheLimit : $limit ); + $num = $queryPage->recache( $limit ?? $wgQueryCacheLimit ); $t2 = microtime( true ); if ( $num === false ) { $this->output( "FAILED: database error\n" ); @@ -119,16 +122,22 @@ class UpdateSpecialPages extends Maintenance { * mysql connection to "go away" */ private function reopenAndWaitForReplicas() { - if ( !wfGetLB()->pingAll() ) { + $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); + $lb = $lbFactory->getMainLB(); + if ( !$lb->pingAll() ) { $this->output( "\n" ); do { $this->error( "Connection failed, reconnecting in 10 seconds..." ); sleep( 10 ); - } while ( !wfGetLB()->pingAll() ); + } while ( !$lb->pingAll() ); $this->output( "Reconnected\n\n" ); } - # Wait for the replica DB to catch up - wfWaitForSlaves(); + // Wait for the replica DB to catch up + try { + $lbFactory->waitForReplication(); + } catch ( DBReplicationWaitError $e ) { + // ignore + } } public function doSpecialPageCacheUpdates( $dbw ) {