X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FupdateSpecialPages.php;h=c5ade2d807a6ce67c2e09326ed3d928b82bc3efe;hb=e3d0d0d3a1080beee67219005514900ba3dc8783;hp=3432cb2070e1bcbb907f324aa378cbf38e9b582b;hpb=9f395ffe9990cd1e763bd21b99e506921451f6b1;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/updateSpecialPages.php b/maintenance/updateSpecialPages.php index 3432cb2070..c5ade2d807 100644 --- a/maintenance/updateSpecialPages.php +++ b/maintenance/updateSpecialPages.php @@ -34,19 +34,18 @@ class UpdateSpecialPages extends Maintenance { parent::__construct(); $this->addOption( 'list', 'List special page names' ); $this->addOption( 'only', 'Only update "page"; case sensitive, ' . - 'check correct case by calling this script with --list or on ' . - 'includes/QueryPage.php. Ex: --only=BrokenRedirects', false, true ); + 'check correct case by calling this script with --list or on ' . + 'includes/QueryPage.php. Ex: --only=BrokenRedirects', false, true ); $this->addOption( 'override', 'Also update pages that have updates disabled' ); } public function execute() { global $IP, $wgQueryPages, $wgQueryCacheLimit, $wgDisableQueryPageUpdate; - if ( !$this->hasOption( 'list' ) && !$this->hasOption( 'only' ) ) { - $this->doSpecialPageCacheUpdates(); - } $dbw = wfGetDB( DB_MASTER ); + $this->doSpecialPageCacheUpdates( $dbw ); + // This is needed to initialise $wgQueryPages require_once "$IP/includes/QueryPage.php"; @@ -56,12 +55,14 @@ class UpdateSpecialPages extends Maintenance { # --list : just show the name of pages if ( $this->hasOption( 'list' ) ) { - $this->output( "$special\n" ); + $this->output( "$special [QueryPage]\n" ); continue; } - if ( !$this->hasOption( 'override' ) && $wgDisableQueryPageUpdate && in_array( $special, $wgDisableQueryPageUpdate ) ) { - $this->output( sprintf( "%-30s disabled\n", $special ) ); + if ( !$this->hasOption( 'override' ) + && $wgDisableQueryPageUpdate && in_array( $special, $wgDisableQueryPageUpdate ) ) + { + $this->output( sprintf( "%-30s [QueryPage] disabled\n", $special ) ); continue; } @@ -81,7 +82,7 @@ class UpdateSpecialPages extends Maintenance { } if ( !$this->hasOption( 'only' ) || $this->getOption( 'only' ) == $queryPage->getName() ) { - $this->output( sprintf( '%-30s ', $special ) ); + $this->output( sprintf( '%-30s [QueryPage] ', $special ) ); if ( $queryPage->isExpensive() ) { $t1 = explode( ' ', microtime() ); # Do the query @@ -112,9 +113,6 @@ class UpdateSpecialPages extends Maintenance { sleep( 10 ); } while ( !wfGetLB()->pingAll() ); $this->output( "Reconnected\n\n" ); - } else { - # Commit the results - $dbw->commit( __METHOD__ ); } # Wait for the slave to catch up wfWaitForSlaves(); @@ -128,32 +126,41 @@ class UpdateSpecialPages extends Maintenance { } } - public function doSpecialPageCacheUpdates() { + public function doSpecialPageCacheUpdates( $dbw ) { global $wgSpecialPageCacheUpdates; - $dbw = wfGetDB( DB_MASTER ); foreach ( $wgSpecialPageCacheUpdates as $special => $call ) { - if ( !is_callable( $call ) ) { - $this->error( "Uncallable function $call!" ); + # --list : just show the name of pages + if ( $this->hasOption( 'list' ) ) { + $this->output( "$special [callback]\n" ); continue; } - $this->output( sprintf( '%-30s ', $special ) ); - $t1 = explode( ' ', microtime() ); - call_user_func( $call, $dbw ); - $t2 = explode( ' ', microtime() ); - $elapsed = ( $t2[0] - $t1[0] ) + ( $t2[1] - $t1[1] ); - $hours = intval( $elapsed / 3600 ); - $minutes = intval( $elapsed % 3600 / 60 ); - $seconds = $elapsed - $hours * 3600 - $minutes * 60; - if ( $hours ) { - $this->output( $hours . 'h ' ); - } - if ( $minutes ) { - $this->output( $minutes . 'm ' ); + + if ( !$this->hasOption( 'only' ) || $this->getOption( 'only' ) == $special ) { + if ( !is_callable( $call ) ) { + $this->error( "Uncallable function $call!" ); + continue; + } + $this->output( sprintf( '%-30s [callback] ', $special ) ); + $t1 = explode( ' ', microtime() ); + call_user_func( $call, $dbw ); + $t2 = explode( ' ', microtime() ); + + $this->output( "completed in " ); + $elapsed = ( $t2[0] - $t1[0] ) + ( $t2[1] - $t1[1] ); + $hours = intval( $elapsed / 3600 ); + $minutes = intval( $elapsed % 3600 / 60 ); + $seconds = $elapsed - $hours * 3600 - $minutes * 60; + if ( $hours ) { + $this->output( $hours . 'h ' ); + } + if ( $minutes ) { + $this->output( $minutes . 'm ' ); + } + $this->output( sprintf( "%.2fs\n", $seconds ) ); + # Wait for the slave to catch up + wfWaitForSlaves(); } - $this->output( sprintf( "completed in %.2fs\n", $seconds ) ); - # Wait for the slave to catch up - wfWaitForSlaves(); } } }