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( $wgSpecialPageCacheUpdates as $special => $call ) {
29 if( !is_callable($call) ) {
30 print "Uncallable function $call!\n";
33 $t1 = explode( ' ', microtime() );
34 call_user_func( $call, $dbw );
35 $t2 = explode( ' ', microtime() );
36 printf( '%-30s ', $special );
37 $elapsed = ($t2[0] - $t1[0]) +
($t2[1] - $t1[1]);
38 $hours = intval( $elapsed / 3600 );
39 $minutes = intval( $elapsed %
3600 / 60 );
40 $seconds = $elapsed - $hours * 3600 - $minutes * 60;
45 print $minutes . 'm ';
47 printf( "completed in %.2fs\n", $seconds );
48 # Wait for the slave to catch up
52 foreach( $wgQueryPages as $page ) {
53 @list
( $class, $special, $limit ) = $page;
55 # --list : just show the name of pages
56 if( @$options['list'] ) {
61 if ( !isset( $options['override'] ) && $wgDisableQueryPageUpdate && in_array( $special, $wgDisableQueryPageUpdate ) ) {
62 printf("%-30s disabled\n", $special);
66 $specialObj = SpecialPage
::getPage( $special );
68 print "No such special page: $special\n";
71 if ( !class_exists( $class ) ) {
72 $file = $specialObj->getFile();
73 require_once( $file );
75 $queryPage = new $class;
77 if( !isset($options['only']) or $options['only'] == $queryPage->getName() ) {
78 printf( '%-30s ', $special );
79 if ( $queryPage->isExpensive() ) {
80 $t1 = explode( ' ', microtime() );
82 $num = $queryPage->recache( $limit === null ?
$wgQueryCacheLimit : $limit );
83 $t2 = explode( ' ', microtime() );
84 if ( $num === false ) {
85 print "FAILED: database error\n";
87 print "got $num rows in ";
89 $elapsed = ($t2[0] - $t1[0]) +
($t2[1] - $t1[1]);
90 $hours = intval( $elapsed / 3600 );
91 $minutes = intval( $elapsed %
3600 / 60 );
92 $seconds = $elapsed - $hours * 3600 - $minutes * 60;
97 print $minutes . 'm ';
99 printf( "%.2fs\n", $seconds );
101 # Reopen any connections that have closed
102 if ( !wfGetLB()->pingAll()) {
105 print "Connection failed, reconnecting in 10 seconds...\n";
107 } while ( !wfGetLB()->pingAll() );
108 print "Reconnected\n\n";
111 $dbw->immediateCommit();
113 # Wait for the slave to catch up
114 wfWaitForSlaves( 5 );
116 print "cheap, skipped\n";