From c1f9b1f7b1b77776192048005dcc66dcf3df2bfb Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 27 Dec 2014 15:41:37 +0100 Subject: Update to MediaWiki 1.24.1 --- maintenance/updateSpecialPages.php | 76 ++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 36 deletions(-) (limited to 'maintenance/updateSpecialPages.php') diff --git a/maintenance/updateSpecialPages.php b/maintenance/updateSpecialPages.php index 3432cb20..61642828 100644 --- a/maintenance/updateSpecialPages.php +++ b/maintenance/updateSpecialPages.php @@ -34,34 +34,32 @@ 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. ' . + 'Ex: --only=BrokenRedirects', false, true ); $this->addOption( 'override', 'Also update pages that have updates disabled' ); } public function execute() { - global $IP, $wgQueryPages, $wgQueryCacheLimit, $wgDisableQueryPageUpdate; + global $wgQueryCacheLimit, $wgDisableQueryPageUpdate; - if ( !$this->hasOption( 'list' ) && !$this->hasOption( 'only' ) ) { - $this->doSpecialPageCacheUpdates(); - } $dbw = wfGetDB( DB_MASTER ); - // This is needed to initialise $wgQueryPages - require_once "$IP/includes/QueryPage.php"; + $this->doSpecialPageCacheUpdates( $dbw ); - foreach ( $wgQueryPages as $page ) { + foreach ( QueryPage::getPages() as $page ) { list( $class, $special ) = $page; $limit = isset( $page[2] ) ? $page[2] : null; # --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 +79,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 +110,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 +123,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(); } } } -- cgit v1.2.2