From ee01bb0d9496855aa6581d1dd909c7d08bd56903 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Mon, 15 Oct 2012 11:16:37 -0400 Subject: [PATCH] Move cache purging out of doUpdates() 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 | 3 ++- includes/installer/DatabaseUpdater.php | 18 +++++++----------- maintenance/update.php | 7 ++++--- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/includes/installer/DatabaseInstaller.php b/includes/installer/DatabaseInstaller.php index de59b2d65f..75ede239b3 100644 --- a/includes/installer/DatabaseInstaller.php +++ b/includes/installer/DatabaseInstaller.php @@ -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; } diff --git a/includes/installer/DatabaseUpdater.php b/includes/installer/DatabaseUpdater.php index 7223003180..740ead528d 100644 --- a/includes/installer/DatabaseUpdater.php +++ b/includes/installer/DatabaseUpdater.php @@ -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" ); } diff --git a/maintenance/update.php b/maintenance/update.php index e3c993badc..cb6f06b2c2 100644 --- a/maintenance/update.php +++ b/maintenance/update.php @@ -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" ); } -- 2.20.1