From da62fc431f62a27a925b6b1d51b4dc21db24c3eb Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Sun, 12 Sep 2010 09:07:51 +0000 Subject: [PATCH] * Use Maintenance::runChild() to get the child script instance * Moved do_stats_init() to DatabaseUpdater and call it from doUpdates() for consistency with purgeCache(), this inverts the order of execution with default messages deletion, but I don't think this should break anything * Removed the early return for postgres, which was a leftover from the old do_postgres_updates() crap --- includes/installer/DatabaseUpdater.php | 19 +++++++++++++++++++ maintenance/update.php | 14 ++------------ maintenance/updaters.inc | 15 --------------- 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/includes/installer/DatabaseUpdater.php b/includes/installer/DatabaseUpdater.php index e9919755c6..fcf489b21d 100644 --- a/includes/installer/DatabaseUpdater.php +++ b/includes/installer/DatabaseUpdater.php @@ -135,6 +135,7 @@ abstract class DatabaseUpdater { if( $purge ) { $this->purgeCache(); } + $this->checkStats(); } /** @@ -376,4 +377,22 @@ abstract class DatabaseUpdater { $this->db->delete( 'objectcache', '*', __METHOD__ ); wfOut( "done.\n" ); } + + /** + * Check the site_stats table is not properly populated. + */ + protected function checkStats() { + wfOut( "Checking site_stats row..." ); + $row = $this->db->selectRow( 'site_stats', '*', array( 'ss_row_id' => 1 ), __METHOD__ ); + if ( $row === false ) { + wfOut( "data is missing! rebuilding...\n" ); + } elseif ( isset( $row->site_stats ) && $row->ss_total_pages == -1 ) { + wfOut( "missing ss_total_pages, rebuilding...\n" ); + } else { + wfOut( "done.\n" ); + return; + } + SiteStatsInit::doAllAndCommit( false ); + } + } diff --git a/maintenance/update.php b/maintenance/update.php index 9dd3e970db..404374de91 100644 --- a/maintenance/update.php +++ b/maintenance/update.php @@ -59,21 +59,11 @@ class UpdateMediaWiki extends Maintenance { $updater = DatabaseUpdater::newForDb( $db, $shared ); $updater->doUpdates( $purge ); - if ( !defined( 'MW_NO_SETUP' ) ) { - define( 'MW_NO_SETUP', true ); - } - foreach( $updater->getPostDatabaseUpdateMaintenance() as $maint ) { - call_user_func_array( array( new $maint, 'execute' ), array() ); + $this->runChild( $maint )->execute(); } - if ( $db->getType() === 'postgres' ) { - return; - } - - do_stats_init(); - - $this->output( "Done.\n" ); + $this->output( "\nDone.\n" ); } protected function afterFinalSetup() { diff --git a/maintenance/updaters.inc b/maintenance/updaters.inc index a217adbbea..4824765c74 100644 --- a/maintenance/updaters.inc +++ b/maintenance/updaters.inc @@ -567,21 +567,6 @@ function maybe_do_profiling_memory_update() { } } -function do_stats_init() { - // Sometimes site_stats table is not properly populated. - wfOut( "\nChecking site_stats row..." ); - $row = wfGetDB( DB_MASTER )->selectRow( 'site_stats', '*', array( 'ss_row_id' => 1 ), __METHOD__ ); - if ( $row === false ) { - wfOut( "data is missing! rebuilding...\n" ); - } elseif ( isset( $row->site_stats ) && $row->ss_total_pages == -1 ) { - wfOut( "missing ss_total_pages, rebuilding...\n" ); - } else { - wfOut( "ok.\n" ); - return; - } - SiteStatsInit::doAllAndCommit( false ); -} - function do_active_users_init() { $dbw = wfGetDB( DB_MASTER ); $activeUsers = $dbw->selectField( 'site_stats', 'ss_active_users', false, __METHOD__ ); -- 2.20.1