Bump $wgStyleVersion to 155.
[lhc/web/wiklou.git] / maintenance / updateSpecialPages.php
1 <?php
2 /**
3 * Run this script periodically if you have miser mode enabled, to refresh the
4 * caches
5 *
6 * @file
7 * @ingroup Maintenance
8 */
9 $options = array('only','help');
10
11 require_once( 'commandLine.inc' );
12
13 require_once( "$IP/includes/SpecialPage.php" );
14 require_once( "$IP/includes/QueryPage.php" );
15
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";
22 wfDie();
23 }
24
25 $wgOut->disable();
26 $dbw = wfGetDB( DB_MASTER );
27
28 foreach ( $wgQueryPages as $page ) {
29 @list( $class, $special, $limit ) = $page;
30
31 # --list : just show the name of pages
32 if( @$options['list'] ) {
33 print "$special\n";
34 continue;
35 }
36
37 if ( !isset( $options['override'] ) && $wgDisableQueryPageUpdate && in_array( $special, $wgDisableQueryPageUpdate ) ) {
38 printf("%-30s disabled\n", $special);
39 continue;
40 }
41
42 $specialObj = SpecialPage::getPage( $special );
43 if ( !$specialObj ) {
44 print "No such special page: $special\n";
45 exit;
46 }
47 if ( !class_exists( $class ) ) {
48 $file = $specialObj->getFile();
49 require_once( $file );
50 }
51 $queryPage = new $class;
52
53 if( !(isset($options['only'])) or ($options['only'] == $queryPage->getName()) ) {
54 printf( '%-30s ', $special );
55
56 if ( $queryPage->isExpensive() ) {
57 $t1 = explode( ' ', microtime() );
58 # Do the query
59 $num = $queryPage->recache( $limit === null ? $wgQueryCacheLimit : $limit );
60 $t2 = explode( ' ', microtime() );
61
62 if ( $num === false ) {
63 print "FAILED: database error\n";
64 } else {
65 print "got $num rows in ";
66
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;
71 if ( $hours ) {
72 print $hours . 'h ';
73 }
74 if ( $minutes ) {
75 print $minutes . 'm ';
76 }
77 printf( "%.2fs\n", $seconds );
78 }
79
80 # Reopen any connections that have closed
81 if ( !wfGetLB()->pingAll()) {
82 print "\n";
83 do {
84 print "Connection failed, reconnecting in 10 seconds...\n";
85 sleep(10);
86 } while ( !wfGetLB()->pingAll() );
87 print "Reconnected\n\n";
88 } else {
89 # Commit the results
90 $dbw->immediateCommit();
91 }
92
93 # Wait for the slave to catch up
94 /*
95 $slaveDB = wfGetDB( DB_SLAVE, array('QueryPage::recache', 'vslow' ) );
96 while( $slaveDB->getLag() > 600 ) {
97 print "Slave lagged, waiting...\n";
98 sleep(30);
99
100 }
101 */
102 wfWaitForSlaves( 5 );
103
104 } else {
105 print "cheap, skipped\n";
106 }
107 }
108 }
109
110