2005-04-24 04:16:50 +00:00
|
|
|
<?php
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
/**
|
|
|
|
|
* Run this script periodically if you have miser mode enabled, to refresh the
|
|
|
|
|
* caches
|
|
|
|
|
*
|
2009-08-02 19:35:17 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
2010-09-01 19:36:18 +00:00
|
|
|
* @file
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Maintenance
|
|
|
|
|
*/
|
2010-12-04 03:20:14 +00:00
|
|
|
|
2010-05-22 16:50:39 +00:00
|
|
|
require_once( dirname( __FILE__ ) . '/Maintenance.php' );
|
2009-06-24 02:49:24 +00:00
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
class UpdateSpecialPages extends Maintenance {
|
|
|
|
|
public function __construct() {
|
|
|
|
|
parent::__construct();
|
|
|
|
|
$this->addOption( 'list', 'List special page names' );
|
|
|
|
|
$this->addOption( 'only', 'Only update "page". Ex: --only=BrokenRedirects', false, true );
|
|
|
|
|
$this->addOption( 'override', 'Also update pages that have updates disabled' );
|
2009-06-24 02:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
public function execute() {
|
2009-10-23 09:40:34 +00:00
|
|
|
global $IP, $wgOut, $wgSpecialPageCacheUpdates, $wgQueryPages, $wgQueryCacheLimit, $wgDisableQueryPageUpdate;
|
2009-08-02 19:35:17 +00:00
|
|
|
$wgOut->disable();
|
|
|
|
|
$dbw = wfGetDB( DB_MASTER );
|
2009-06-24 02:49:24 +00:00
|
|
|
|
2010-05-22 16:50:39 +00:00
|
|
|
foreach ( $wgSpecialPageCacheUpdates as $special => $call ) {
|
|
|
|
|
if ( !is_callable( $call ) ) {
|
2009-08-02 21:55:10 +00:00
|
|
|
$this->error( "Uncallable function $call!" );
|
2009-08-02 19:35:17 +00:00
|
|
|
continue;
|
|
|
|
|
}
|
2008-08-31 19:29:37 +00:00
|
|
|
$t1 = explode( ' ', microtime() );
|
2009-08-02 19:35:17 +00:00
|
|
|
call_user_func( $call, $dbw );
|
2008-08-31 19:29:37 +00:00
|
|
|
$t2 = explode( ' ', microtime() );
|
2009-08-02 19:35:17 +00:00
|
|
|
$this->output( sprintf( '%-30s ', $special ) );
|
2010-05-22 16:50:39 +00:00
|
|
|
$elapsed = ( $t2[0] - $t1[0] ) + ( $t2[1] - $t1[1] );
|
2009-08-02 19:35:17 +00:00
|
|
|
$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( "completed in %.2fs\n", $seconds ) );
|
|
|
|
|
# Wait for the slave to catch up
|
|
|
|
|
wfWaitForSlaves( 5 );
|
|
|
|
|
}
|
2009-08-02 19:49:24 +00:00
|
|
|
|
2009-08-07 14:05:26 +00:00
|
|
|
// This is needed to initialise $wgQueryPages
|
|
|
|
|
require_once( "$IP/includes/QueryPage.php" );
|
|
|
|
|
|
2010-05-22 16:50:39 +00:00
|
|
|
foreach ( $wgQueryPages as $page ) {
|
2009-08-02 19:35:17 +00:00
|
|
|
@list( $class, $special, $limit ) = $page;
|
2009-11-23 18:20:26 +00:00
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
# --list : just show the name of pages
|
2010-05-22 16:50:39 +00:00
|
|
|
if ( $this->hasOption( 'list' ) ) {
|
2009-08-02 19:35:17 +00:00
|
|
|
$this->output( "$special\n" );
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2009-11-23 18:20:26 +00:00
|
|
|
|
2010-05-22 16:50:39 +00:00
|
|
|
if ( !$this->hasOption( 'override' ) && $wgDisableQueryPageUpdate && in_array( $special, $wgDisableQueryPageUpdate ) ) {
|
2009-08-02 19:35:17 +00:00
|
|
|
$this->output( sprintf( "%-30s disabled\n", $special ) );
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2009-11-23 18:20:26 +00:00
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
$specialObj = SpecialPage::getPage( $special );
|
|
|
|
|
if ( !$specialObj ) {
|
|
|
|
|
$this->output( "No such special page: $special\n" );
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
if ( !class_exists( $class ) ) {
|
|
|
|
|
$file = $specialObj->getFile();
|
|
|
|
|
require_once( $file );
|
|
|
|
|
}
|
|
|
|
|
$queryPage = new $class;
|
2009-11-23 18:20:26 +00:00
|
|
|
|
2010-05-22 16:50:39 +00:00
|
|
|
if ( !$this->hasOption( 'only' ) || $this->getOption( 'only' ) == $queryPage->getName() ) {
|
2009-08-02 19:35:17 +00:00
|
|
|
$this->output( sprintf( '%-30s ', $special ) );
|
|
|
|
|
if ( $queryPage->isExpensive() ) {
|
|
|
|
|
$t1 = explode( ' ', microtime() );
|
|
|
|
|
# Do the query
|
|
|
|
|
$num = $queryPage->recache( $limit === null ? $wgQueryCacheLimit : $limit );
|
|
|
|
|
$t2 = explode( ' ', microtime() );
|
|
|
|
|
if ( $num === false ) {
|
|
|
|
|
$this->output( "FAILED: database error\n" );
|
|
|
|
|
} else {
|
|
|
|
|
$this->output( "got $num rows in " );
|
2009-11-23 18:20:26 +00:00
|
|
|
|
2010-05-22 16:50:39 +00:00
|
|
|
$elapsed = ( $t2[0] - $t1[0] ) + ( $t2[1] - $t1[1] );
|
2009-08-02 19:35:17 +00:00
|
|
|
$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 ) );
|
2009-08-07 14:05:26 +00:00
|
|
|
}
|
|
|
|
|
# Reopen any connections that have closed
|
2010-05-22 16:50:39 +00:00
|
|
|
if ( !wfGetLB()->pingAll() ) {
|
2009-08-07 14:05:26 +00:00
|
|
|
$this->output( "\n" );
|
|
|
|
|
do {
|
|
|
|
|
$this->error( "Connection failed, reconnecting in 10 seconds..." );
|
|
|
|
|
sleep( 10 );
|
|
|
|
|
} while ( !wfGetLB()->pingAll() );
|
|
|
|
|
$this->output( "Reconnected\n\n" );
|
|
|
|
|
} else {
|
|
|
|
|
# Commit the results
|
2009-12-14 23:18:03 +00:00
|
|
|
$dbw->commit();
|
2009-08-07 14:05:26 +00:00
|
|
|
}
|
|
|
|
|
# Wait for the slave to catch up
|
|
|
|
|
wfWaitForSlaves( 5 );
|
2009-08-02 19:35:17 +00:00
|
|
|
} else {
|
|
|
|
|
$this->output( "cheap, skipped\n" );
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-08-31 19:29:37 +00:00
|
|
|
}
|
2005-07-10 18:23:06 +00:00
|
|
|
}
|
2005-04-24 04:16:50 +00:00
|
|
|
}
|
2009-08-02 19:35:17 +00:00
|
|
|
|
|
|
|
|
$maintClass = "UpdateSpecialPages";
|
|
|
|
|
require_once( DO_MAINTENANCE );
|