From: Platonides Date: Wed, 27 Oct 2010 14:38:31 +0000 (+0000) Subject: Make update.php obey --quiet X-Git-Tag: 1.31.0-rc.0~34272 X-Git-Url: http://git.cyclocoop.org/%24self?a=commitdiff_plain;h=051fd4105307e1227c054e17ed5fee25387c88d3;p=lhc%2Fweb%2Fwiklou.git Make update.php obey --quiet --- diff --git a/includes/installer/DatabaseUpdater.php b/includes/installer/DatabaseUpdater.php index bb7bf1171e..5b8b9f05f7 100644 --- a/includes/installer/DatabaseUpdater.php +++ b/includes/installer/DatabaseUpdater.php @@ -37,14 +37,20 @@ abstract class DatabaseUpdater { * * @param $db DatabaseBase object to perform updates on * @param $shared bool Whether to perform updates on shared tables + * @param $maintenance Maintenance Maintenance object which created us * * @TODO @FIXME Make $wgDatabase go away. */ - protected function __construct( DatabaseBase &$db, $shared ) { + protected function __construct( DatabaseBase &$db, $shared, Maintenance $maintenance = null ) { global $wgDatabase; $wgDatabase = $db; $this->db = $db; $this->shared = $shared; + if ( $maintenance ) { + $this->maintenance = $maintenance; + } else { + $this->maintenance = new FakeMaintenance; + } $this->initOldGlobals(); wfRunHooks( 'LoadExtensionSchemaUpdates', array( $this ) ); } @@ -67,11 +73,11 @@ abstract class DatabaseUpdater { $wgExtModifiedFields = array(); // table, index, dir } - public static function newForDB( &$db, $shared = false ) { + public static function newForDB( &$db, $shared = false, $maintenance = null ) { $type = $db->getType(); if( in_array( $type, Installer::getDBTypes() ) ) { $class = ucfirst( $type ) . 'Updater'; - return new $class( $db, $shared ); + return new $class( $db, $shared, $maintenance ); } else { throw new MWException( __METHOD__ . ' called for unsupported $wgDBtype' ); } @@ -93,6 +99,9 @@ abstract class DatabaseUpdater { * @param $str String: Text to output */ protected function output( $str ) { + if ( $this->maintenance->isQuiet() ) { + return; + } wfOut( $str ); } @@ -210,7 +219,7 @@ abstract class DatabaseUpdater { /** * Before 1.17, we used to handle updates via stuff like * $wgExtNewTables/Fields/Indexes. This is nasty :) We refactored a lot - * of this in 1.17 but we want to remain back-compatible for awhile. So + * of this in 1.17 but we want to remain back-compatible for a while. So * load up these old global-based things into our update list. */ protected function getOldGlobalUpdates() { diff --git a/includes/installer/MysqlUpdater.php b/includes/installer/MysqlUpdater.php index 4550e057fa..1d187705f6 100644 --- a/includes/installer/MysqlUpdater.php +++ b/includes/installer/MysqlUpdater.php @@ -253,7 +253,7 @@ class MysqlUpdater extends DatabaseUpdater { } protected function doOldLinksUpdate() { - $cl = new ConvertLinks(); + $cl = $this->maintenance->runChild( 'ConvertLinks' ); $cl->execute(); } @@ -696,7 +696,7 @@ class MysqlUpdater extends DatabaseUpdater { $this->output( "ok\n" ); $this->output( "Migrating old restrictions to new table...\n" ); - $task = new UpdateRestrictions(); + $task = $this->maintenance->runChild( 'UpdateRestrictions' ); $task->execute(); } @@ -719,7 +719,7 @@ class MysqlUpdater extends DatabaseUpdater { "may want to hit Ctrl-C and do this manually with maintenance/\n" . "populateCategory.php.\n" ); - $task = new PopulateCategory(); + $task = $this->maintenance->runChild( 'PopulateCategory' ); $task->execute(); $this->output( "Done populating category table.\n" ); } @@ -730,7 +730,7 @@ class MysqlUpdater extends DatabaseUpdater { return; } - $task = new PopulateParentId(); + $task = $this->maintenance->runChild( 'PopulateParentId' ); $task->execute(); } @@ -794,7 +794,7 @@ class MysqlUpdater extends DatabaseUpdater { return; } - $task = new PopulateRevisionLength(); + $task = $this->maintenance->runChild( 'PopulateRevisionLength' ); $task->execute(); } diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index 714f51fe22..1d0cc58aed 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -229,6 +229,10 @@ abstract class Maintenance { return rtrim( $input ); } + public function isQuiet() { + return $this->mQuiet; + } + /** * Throw some output to the user. Scripts can call this with no fears, * as we handle all --quiet stuff here @@ -366,7 +370,7 @@ abstract class Maintenance { * @param $classFile String: full path of where the child is * @return Maintenance child */ - protected function runChild( $maintClass, $classFile = null ) { + public function runChild( $maintClass, $classFile = null ) { // If we haven't already specified, kill setup procedures // for child scripts, we've already got a sane environment self::disableSetup(); @@ -1032,3 +1036,10 @@ abstract class Maintenance { } } + +class FakeMaintenance extends Maintenance { + public function execute() { + return; + } +} + diff --git a/maintenance/update.php b/maintenance/update.php index 57ce9aaafe..fe030ee050 100644 --- a/maintenance/update.php +++ b/maintenance/update.php @@ -64,7 +64,7 @@ class UpdateMediaWiki extends Maintenance { $shared = $this->hasOption( 'doshared' ); $purge = !$this->hasOption( 'nopurge' ); - $updater = DatabaseUpdater::newForDb( $db, $shared ); + $updater = DatabaseUpdater::newForDb( $db, $shared, $this ); $updater->doUpdates( $purge ); foreach( $updater->getPostDatabaseUpdateMaintenance() as $maint ) {