From 11d0feb8cf66cbf0884a26ad36f346d09fd98bf8 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Fri, 21 Nov 2008 06:46:31 +0000 Subject: [PATCH] (bug 8702) Refactor stats updating in nukePage. Now updates edit count and good article count, not just total page count. --- RELEASE-NOTES | 1 + maintenance/nukePage.inc | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index d06dd2d22c..e9b6ee246f 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -359,6 +359,7 @@ The following extensions are migrated into MediaWiki 1.14: * Improved scripting safety heuristics for IE 5/6 content-type detection. * Improved scripting safety heuristics on SVG uploads. * (bug 11728) Unify layout of enhanced watchlist/recent changes +* (bug 8702) Properly update stats when running nukePage maintenance script === API changes in 1.14 === diff --git a/maintenance/nukePage.inc b/maintenance/nukePage.inc index 9ac280349a..a19c6df6f4 100644 --- a/maintenance/nukePage.inc +++ b/maintenance/nukePage.inc @@ -25,6 +25,7 @@ function NukePage( $name, $delete = false ) { if( $title ) { $id = $title->getArticleID(); $real = $title->getPrefixedText(); + $isGoodArticle = $title->isContentPage(); echo( "found \"$real\" with ID $id.\n" ); # Get corresponding revisions @@ -56,6 +57,16 @@ function NukePage( $name, $delete = false ) { PurgeRedundantText( true ); } + # Update stats as appropriate + if ( $delete ) { + echo( "Updating site stats..." ); + $ga = $isGoodArticle ? -1 : 0; // if it was good, decrement that too + $stats = new SiteStatsUpdate( 0, -$count, $ga, -1 ); + $stats->doUpdate(); + echo( "done.\n" ); + } + + } else { echo( "not found in database.\n" ); $dbw->commit(); @@ -74,14 +85,6 @@ function DeleteRevisions( $ids ) { $dbw->query( "DELETE FROM $tbl_rev WHERE rev_id IN ( $set )" ); $dbw->commit(); - - #TODO: see if this is a "good" page, to decrement that as well. - $pages = $dbw->selectField('site_stats', 'ss_total_pages'); - $pages--; - $dbw->update( 'site_stats', - array('ss_total_pages' => $pages ), - array( 'ss_row_id' => 1), - __METHOD__ ); } -- 2.20.1