X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FupdateSpecialPages.php;h=1c6f9b339dffda4596d687a2c5842ab5f0536eed;hb=e2f61aa44095d56af0d4b25a59e25b55a6c297bc;hp=5ea3828214ac5157036ed83ebdd63d1c7a0a5b0e;hpb=7874fc4bec845ad92960b07e969c65f3c3fe74f2;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/updateSpecialPages.php b/maintenance/updateSpecialPages.php index 5ea3828214..1c6f9b339d 100644 --- a/maintenance/updateSpecialPages.php +++ b/maintenance/updateSpecialPages.php @@ -72,7 +72,7 @@ class UpdateSpecialPages extends Maintenance { $queryPage = $specialObj; } else { $class = get_class( $specialObj ); - $this->error( "$class is not an instance of QueryPage.\n", 1 ); + $this->fatalError( "$class is not an instance of QueryPage.\n" ); die; } @@ -101,16 +101,7 @@ class UpdateSpecialPages extends Maintenance { $this->output( sprintf( "%.2fs\n", $seconds ) ); } # Reopen any connections that have closed - if ( !wfGetLB()->pingAll() ) { - $this->output( "\n" ); - do { - $this->error( "Connection failed, reconnecting in 10 seconds..." ); - sleep( 10 ); - } while ( !wfGetLB()->pingAll() ); - $this->output( "Reconnected\n\n" ); - } - # Wait for the replica DB to catch up - wfWaitForSlaves(); + $this->reopenAndWaitForReplicas(); } else { $this->output( "cheap, skipped\n" ); } @@ -121,6 +112,25 @@ class UpdateSpecialPages extends Maintenance { } } + /** + * Re-open any closed db connection, and wait for replicas + * + * Queries that take a really long time, might cause the + * mysql connection to "go away" + */ + private function reopenAndWaitForReplicas() { + if ( !wfGetLB()->pingAll() ) { + $this->output( "\n" ); + do { + $this->error( "Connection failed, reconnecting in 10 seconds..." ); + sleep( 10 ); + } while ( !wfGetLB()->pingAll() ); + $this->output( "Reconnected\n\n" ); + } + # Wait for the replica DB to catch up + wfWaitForSlaves(); + } + public function doSpecialPageCacheUpdates( $dbw ) { global $wgSpecialPageCacheUpdates; @@ -154,11 +164,11 @@ class UpdateSpecialPages extends Maintenance { } $this->output( sprintf( "%.2fs\n", $seconds ) ); # Wait for the replica DB to catch up - wfWaitForSlaves(); + $this->reopenAndWaitForReplicas(); } } } } -$maintClass = "UpdateSpecialPages"; +$maintClass = UpdateSpecialPages::class; require_once RUN_MAINTENANCE_IF_MAIN;