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 " --only=page : only update 'page'. Ex: --only=BrokenRedirects\n";
19 $dbw =& wfGetDB( DB_MASTER
);
21 foreach ( $wgQueryPages as $page ) {
22 @list
( $class, $special, $limit ) = $page;
24 $specialObj = SpecialPage
::getPage( $special );
26 print "No such special page: $special\n";
29 $file = $specialObj->getFile();
31 require_once( $file );
33 $queryPage = new $class;
35 if( !(isset($options['only'])) or ($options['only'] == $queryPage->getName()) ) {
36 printf( '%-30s', $special );
38 if ( $queryPage->isExpensive() ) {
39 $t1 = explode( ' ', microtime() );
41 $num = $queryPage->recache( $limit === null ?
1000 : $limit );
42 $t2 = explode( ' ', microtime() );
44 if ( $num === false ) {
45 print "FAILED: database error\n";
47 print "got $num rows in ";
49 $elapsed = ($t2[0] - $t1[0]) +
($t2[1] - $t1[1]);
50 $hours = intval( $elapsed / 3600 );
51 $minutes = intval( $elapsed %
3600 / 60 );
52 $seconds = $elapsed - $hours * 3600 - $minutes * 60;
57 print $minutes . 'm ';
59 printf( "%.2fs\n", $seconds );
62 # Reopen any connections that have closed
63 if ( !$wgLoadBalancer->pingAll()) {
66 print "Connection failed, reconnecting in 10 seconds...\n";
68 } while ( !$wgLoadBalancer->pingAll() );
69 print "Reconnected\n\n";
72 $dbw->immediateCommit();
75 # Wait for the slave to catch up
76 $slaveDB =& wfGetDB( DB_SLAVE
, array('QueryPage::recache', 'vslow' ) );
77 while( $slaveDB->getLag() > 600 ) {
78 print "Slave lagged, waiting...\n";
84 print "cheap, skipped\n";