3 # Run this script periodically if you have miser mode enabled, to refresh the caches
4 $options = array('only','help');
6 require_once( 'commandLine.inc' );
8 require_once( 'SpecialPage.php' );
9 require_once( 'QueryPage.php' );
11 if(@$options['help']) {
12 print "usage:updateSpecialPages.php [--help] [--only=page]\n";
13 print " --help : this help message\n";
14 print " --list : list special pages names\n";
15 print " --only=page : only update 'page'. Ex: --only=BrokenRedirects\n";
20 $dbw =& wfGetDB( DB_MASTER
);
22 foreach ( $wgQueryPages as $page ) {
23 @list
( $class, $special, $limit ) = $page;
25 # --list : just show the name of pages
26 if( @$options['list'] ) {
31 $specialObj = SpecialPage
::getPage( $special );
33 print "No such special page: $special\n";
36 $file = $specialObj->getFile();
38 require_once( $file );
40 $queryPage = new $class;
42 if( !(isset($options['only'])) or ($options['only'] == $queryPage->getName()) ) {
43 printf( '%-30s', $special );
45 if ( $queryPage->isExpensive() ) {
46 $t1 = explode( ' ', microtime() );
48 $num = $queryPage->recache( $limit === null ?
1000 : $limit );
49 $t2 = explode( ' ', microtime() );
51 if ( $num === false ) {
52 print "FAILED: database error\n";
54 print "got $num rows in ";
56 $elapsed = ($t2[0] - $t1[0]) +
($t2[1] - $t1[1]);
57 $hours = intval( $elapsed / 3600 );
58 $minutes = intval( $elapsed %
3600 / 60 );
59 $seconds = $elapsed - $hours * 3600 - $minutes * 60;
64 print $minutes . 'm ';
66 printf( "%.2fs\n", $seconds );
69 # Reopen any connections that have closed
70 if ( !$wgLoadBalancer->pingAll()) {
73 print "Connection failed, reconnecting in 10 seconds...\n";
75 } while ( !$wgLoadBalancer->pingAll() );
76 print "Reconnected\n\n";
79 $dbw->immediateCommit();
82 # Wait for the slave to catch up
83 $slaveDB =& wfGetDB( DB_SLAVE
, array('QueryPage::recache', 'vslow' ) );
84 while( $slaveDB->getLag() > 600 ) {
85 print "Slave lagged, waiting...\n";
91 print "cheap, skipped\n";