3 * Run this script periodically if you have miser mode enabled, to refresh the
9 $options = array('only','help');
11 require_once( 'commandLine.inc' );
13 require_once( "$IP/includes/SpecialPage.php" );
14 require_once( "$IP/includes/QueryPage.php" );
16 if(@$options['help']) {
17 print "usage:updateSpecialPages.php [--help] [--only=page]\n";
18 print " --help : this help message\n";
19 print " --list : list special pages names\n";
20 print " --only=page : only update 'page'. Ex: --only=BrokenRedirects\n";
21 print " --override : update even pages which have had updates disabled\n";
26 $dbw = wfGetDB( DB_MASTER
);
28 foreach ( $wgQueryPages as $page ) {
29 @list
( $class, $special, $limit ) = $page;
31 # --list : just show the name of pages
32 if( @$options['list'] ) {
37 if ( !isset( $options['override'] ) && $wgDisableQueryPageUpdate && in_array( $special, $wgDisableQueryPageUpdate ) ) {
38 printf("%-30s disabled\n", $special);
42 $specialObj = SpecialPage
::getPage( $special );
44 print "No such special page: $special\n";
47 if ( !class_exists( $class ) ) {
48 $file = $specialObj->getFile();
49 require_once( $file );
51 $queryPage = new $class;
53 if( !(isset($options['only'])) or ($options['only'] == $queryPage->getName()) ) {
54 printf( '%-30s ', $special );
56 if ( $queryPage->isExpensive() ) {
57 $t1 = explode( ' ', microtime() );
59 $num = $queryPage->recache( $limit === null ?
$wgQueryCacheLimit : $limit );
60 $t2 = explode( ' ', microtime() );
62 if ( $num === false ) {
63 print "FAILED: database error\n";
65 print "got $num rows in ";
67 $elapsed = ($t2[0] - $t1[0]) +
($t2[1] - $t1[1]);
68 $hours = intval( $elapsed / 3600 );
69 $minutes = intval( $elapsed %
3600 / 60 );
70 $seconds = $elapsed - $hours * 3600 - $minutes * 60;
75 print $minutes . 'm ';
77 printf( "%.2fs\n", $seconds );
80 # Reopen any connections that have closed
81 if ( !wfGetLB()->pingAll()) {
84 print "Connection failed, reconnecting in 10 seconds...\n";
86 } while ( !wfGetLB()->pingAll() );
87 print "Reconnected\n\n";
90 $dbw->immediateCommit();
93 # Wait for the slave to catch up
95 $slaveDB = wfGetDB( DB_SLAVE, array('QueryPage::recache', 'vslow' ) );
96 while( $slaveDB->getLag() > 600 ) {
97 print "Slave lagged, waiting...\n";
102 wfWaitForSlaves( 5 );
105 print "cheap, skipped\n";