Maintenance script to recount images and update the site statistics
[lhc/web/wiklou.git] / maintenance / recountImages.php
1 <?php
2
3 /**
4 * Maintenance script to update the site_stats.ss_images field
5 *
6 * @package MediaWiki
7 * @subpackage Maintenance
8 * @author Rob Church <robchur@gmail.com>
9 * @licence GNU General Public Licence 2.0 or later
10 */
11
12 require_once( 'commandLine.inc' );
13
14 function recountImages() {
15 $dbw =& wfGetDB( DB_MASTER );
16 $count = $dbw->selectField( 'images', 'COUNT(*)', '', 'recountImages' );
17 # Replication safe update; set to NULL first to force the change to slaves
18 $dbw->update( 'site_stats', array( 'ss_images' => NULL ), array( 'ss_row_id' => 1 ), 'recountImages' );
19 $dbw->update( 'site_stats', array( 'ss_images' => $count ), array( 'ss_row_id' => 1 ), 'recountImages' );
20 return $count;
21 }
22
23 echo( "Updating image count in site statistics..." );
24 recountImages();
25 echo( "set to {$count}.\n\n" );
26
27 ?>