* Use Maintenance::runChild() to get the child script instance
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sun, 12 Sep 2010 09:07:51 +0000 (09:07 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sun, 12 Sep 2010 09:07:51 +0000 (09:07 +0000)
* 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
maintenance/update.php
maintenance/updaters.inc

index e991975..fcf489b 100644 (file)
@@ -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 );
+       }
+
 }
index 9dd3e97..404374d 100644 (file)
@@ -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() {
index a217adb..4824765 100644 (file)
@@ -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__ );