From 56a1fb2647945e227a3132c9c44b7d8174210c42 Mon Sep 17 00:00:00 2001 From: Rob Church Date: Mon, 1 May 2006 15:22:56 +0000 Subject: [PATCH] Maintenance script to recount images and update the site statistics --- RELEASE-NOTES | 1 + maintenance/recountImages.php | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 maintenance/recountImages.php diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 5e0ad4d806..dd1ab18844 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -178,6 +178,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN formatted according to the current user's settings * (bug 218) Redirects do not support named anchors * (bug 5780) Thousands and decimal separators for Norwegian +* Maintenance script to recount images and update the site statistics == Compatibility == diff --git a/maintenance/recountImages.php b/maintenance/recountImages.php new file mode 100644 index 0000000000..613082feb9 --- /dev/null +++ b/maintenance/recountImages.php @@ -0,0 +1,27 @@ + + * @licence GNU General Public Licence 2.0 or later + */ + +require_once( 'commandLine.inc' ); + +function recountImages() { + $dbw =& wfGetDB( DB_MASTER ); + $count = $dbw->selectField( 'images', 'COUNT(*)', '', 'recountImages' ); + # Replication safe update; set to NULL first to force the change to slaves + $dbw->update( 'site_stats', array( 'ss_images' => NULL ), array( 'ss_row_id' => 1 ), 'recountImages' ); + $dbw->update( 'site_stats', array( 'ss_images' => $count ), array( 'ss_row_id' => 1 ), 'recountImages' ); + return $count; +} + +echo( "Updating image count in site statistics..." ); +recountImages(); +echo( "set to {$count}.\n\n" ); + +?> \ No newline at end of file -- 2.20.1