Move cache purging out of doUpdates()
authorChad Horohoe <chadh@wikimedia.org>
Mon, 15 Oct 2012 15:16:37 +0000 (11:16 -0400)
committerChad Horohoe <chadh@wikimedia.org>
Thu, 25 Oct 2012 18:21:34 +0000 (14:21 -0400)
It makes a whole lot more sense to run this at the end of the
update process after post update maintenance rather than just
at the end of schema updates.

Run update.php more than once so all the updatelog entries
are populated and you'll see why it makes sense.

Change-Id: Ice42a31dee1e6b41da4aa0a47e8786579382aff1

includes/installer/DatabaseInstaller.php
includes/installer/DatabaseUpdater.php
maintenance/update.php

index de59b2d..75ede23 100644 (file)
@@ -269,14 +269,15 @@ abstract class DatabaseInstaller {
 
                $ret = true;
                ob_start( array( $this, 'outputHandler' ) );
+               $up = DatabaseUpdater::newForDB( $this->db );
                try {
-                       $up = DatabaseUpdater::newForDB( $this->db );
                        $up->doUpdates();
                } catch ( MWException $e ) {
                        echo "\nAn error occurred:\n";
                        echo $e->getText();
                        $ret = false;
                }
+               $up->purgeCache();
                ob_end_flush();
                return $ret;
        }
index 7223003..740ead5 100644 (file)
@@ -292,8 +292,8 @@ abstract class DatabaseUpdater {
         *
         * @param $what Array: what updates to perform
         */
-       public function doUpdates( $what = array( 'core', 'extensions', 'purge', 'stats' ) ) {
-               global $wgLocalisationCacheConf, $wgVersion;
+       public function doUpdates( $what = array( 'core', 'extensions', 'stats' ) ) {
+               global $wgVersion;
 
                $this->db->begin( __METHOD__ );
                $what = array_flip( $what );
@@ -310,14 +310,6 @@ abstract class DatabaseUpdater {
                if ( isset( $what['stats'] ) ) {
                        $this->checkStats();
                }
-
-               if ( isset( $what['purge'] ) ) {
-                       $this->purgeCache();
-
-                       if ( $wgLocalisationCacheConf['manualRecache'] ) {
-                               $this->rebuildLocalisationCache();
-                       }
-               }
                $this->db->commit( __METHOD__ );
        }
 
@@ -617,11 +609,15 @@ abstract class DatabaseUpdater {
        /**
         * Purge the objectcache table
         */
-       protected function purgeCache() {
+       public function purgeCache() {
+               global $wgLocalisationCacheConf;
                # We can't guarantee that the user will be able to use TRUNCATE,
                # but we know that DELETE is available to us
                $this->output( "Purging caches..." );
                $this->db->delete( 'objectcache', '*', __METHOD__ );
+               if ( $wgLocalisationCacheConf['manualRecache'] ) {
+                       $this->rebuildLocalisationCache();
+               }
                $this->output( "done.\n" );
        }
 
index e3c993b..cb6f06b 100644 (file)
@@ -118,9 +118,6 @@ class UpdateMediaWiki extends Maintenance {
                $shared = $this->hasOption( 'doshared' );
 
                $updates = array( 'core', 'extensions', 'stats' );
-               if( !$this->hasOption('nopurge') ) {
-                       $updates[] = 'purge';
-               }
 
                $updater = DatabaseUpdater::newForDb( $db, $shared, $this );
                $updater->doUpdates( $updates );
@@ -140,6 +137,10 @@ class UpdateMediaWiki extends Maintenance {
                        }
                }
 
+               if( !$this->hasOption('nopurge') ) {
+                       $updater->purgeCache();
+               }
+
                $this->output( "\nDone.\n" );
        }