New updateSpecialPages.php script, to update the QueryPage cache. Disabled recache...
[lhc/web/wiklou.git] / maintenance / updateSpecialPages.php
1 <?php
2
3 # Run this script periodically if you have miser mode enabled, to refresh the caches
4
5 require_once( 'commandLine.inc' );
6
7 require_once( 'SpecialPage.php' );
8 require_once( 'QueryPage.php' );
9
10 $wgOut->disable();
11
12 foreach ( $wgQueryPages as $page ) {
13 list( $class, $special ) = $page;
14
15 $specialObj = SpecialPage::getPage( $special );
16 if ( !$specialObj ) {
17 print "No such special page: $special\n";
18 exit;
19 }
20 $file = $specialObj->getFile();
21 if ( $file ) {
22 require_once( $file );
23 }
24 $queryPage = new $class;
25
26 printf( '%-30s', $special );
27
28 if ( $queryPage->isExpensive() ) {
29 $t1 = explode( ' ', microtime() );
30 $num = $queryPage->doQuery( 0, 0, true );
31 $t2 = explode( ' ', microtime() );
32
33 print "got $num rows in ";
34
35 $elapsed = ($t2[0] - $t1[0]) + ($t2[1] - $t1[1]);
36 $hours = intval( $elapsed / 3600 );
37 $minutes = intval( $elapsed % 3600 / 60 );
38 $seconds = $elapsed - $hours * 3600 - $minutes * 60;
39 if ( $hours ) {
40 print $hours . 'h ';
41 }
42 if ( $minutes ) {
43 print $minutes . 'm ';
44 }
45 printf( "%.2f s\n", $seconds );
46 } else {
47 print "cheap, skipped\n";
48 }
49 }
50
51 ?>