From: Aaron Schulz Date: Thu, 30 Jan 2014 17:47:21 +0000 (-0800) Subject: Made UpdateSpecialPages support --list/--only with the callback updates X-Git-Tag: 1.31.0-rc.0~17014 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=commitdiff_plain;h=1baaa740ba7847391870e150bf4c0bd4a4658b79;p=lhc%2Fweb%2Fwiklou.git Made UpdateSpecialPages support --list/--only with the callback updates * Fixed some timing output calls Change-Id: I7bbb9123def51c703c1b77bbd946316c6a264d0f --- diff --git a/maintenance/updateSpecialPages.php b/maintenance/updateSpecialPages.php index 40c6951c65..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 @@ -125,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(); } } }