r75542 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75541‎ | r75542 | r75543 >
Date:14:38, 27 October 2010
Author:platonides
Status:resolved
Tags:
Comment:
Make update.php obey --quiet
Modified paths:
  • /trunk/phase3/includes/installer/DatabaseUpdater.php (modified) (history)
  • /trunk/phase3/includes/installer/MysqlUpdater.php (modified) (history)
  • /trunk/phase3/maintenance/Maintenance.php (modified) (history)
  • /trunk/phase3/maintenance/update.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/update.php
@@ -64,7 +64,7 @@
6565 $shared = $this->hasOption( 'doshared' );
6666 $purge = !$this->hasOption( 'nopurge' );
6767
68 - $updater = DatabaseUpdater::newForDb( $db, $shared );
 68+ $updater = DatabaseUpdater::newForDb( $db, $shared, $this );
6969 $updater->doUpdates( $purge );
7070
7171 foreach( $updater->getPostDatabaseUpdateMaintenance() as $maint ) {
Index: trunk/phase3/maintenance/Maintenance.php
@@ -229,6 +229,10 @@
230230 return rtrim( $input );
231231 }
232232
 233+ public function isQuiet() {
 234+ return $this->mQuiet;
 235+ }
 236+
233237 /**
234238 * Throw some output to the user. Scripts can call this with no fears,
235239 * as we handle all --quiet stuff here
@@ -366,7 +370,7 @@
367371 * @param $classFile String: full path of where the child is
368372 * @return Maintenance child
369373 */
370 - protected function runChild( $maintClass, $classFile = null ) {
 374+ public function runChild( $maintClass, $classFile = null ) {
371375 // If we haven't already specified, kill setup procedures
372376 // for child scripts, we've already got a sane environment
373377 self::disableSetup();
@@ -1032,3 +1036,10 @@
10331037 }
10341038
10351039 }
 1040+
 1041+class FakeMaintenance extends Maintenance {
 1042+ public function execute() {
 1043+ return;
 1044+ }
 1045+}
 1046+
Index: trunk/phase3/includes/installer/DatabaseUpdater.php
@@ -37,14 +37,20 @@
3838 *
3939 * @param $db DatabaseBase object to perform updates on
4040 * @param $shared bool Whether to perform updates on shared tables
 41+ * @param $maintenance Maintenance Maintenance object which created us
4142 *
4243 * @TODO @FIXME Make $wgDatabase go away.
4344 */
44 - protected function __construct( DatabaseBase &$db, $shared ) {
 45+ protected function __construct( DatabaseBase &$db, $shared, Maintenance $maintenance = null ) {
4546 global $wgDatabase;
4647 $wgDatabase = $db;
4748 $this->db = $db;
4849 $this->shared = $shared;
 50+ if ( $maintenance ) {
 51+ $this->maintenance = $maintenance;
 52+ } else {
 53+ $this->maintenance = new FakeMaintenance;
 54+ }
4955 $this->initOldGlobals();
5056 wfRunHooks( 'LoadExtensionSchemaUpdates', array( $this ) );
5157 }
@@ -67,11 +73,11 @@
6874 $wgExtModifiedFields = array(); // table, index, dir
6975 }
7076
71 - public static function newForDB( &$db, $shared = false ) {
 77+ public static function newForDB( &$db, $shared = false, $maintenance = null ) {
7278 $type = $db->getType();
7379 if( in_array( $type, Installer::getDBTypes() ) ) {
7480 $class = ucfirst( $type ) . 'Updater';
75 - return new $class( $db, $shared );
 81+ return new $class( $db, $shared, $maintenance );
7682 } else {
7783 throw new MWException( __METHOD__ . ' called for unsupported $wgDBtype' );
7884 }
@@ -93,6 +99,9 @@
94100 * @param $str String: Text to output
95101 */
96102 protected function output( $str ) {
 103+ if ( $this->maintenance->isQuiet() ) {
 104+ return;
 105+ }
97106 wfOut( $str );
98107 }
99108
@@ -210,7 +219,7 @@
211220 /**
212221 * Before 1.17, we used to handle updates via stuff like
213222 * $wgExtNewTables/Fields/Indexes. This is nasty :) We refactored a lot
214 - * of this in 1.17 but we want to remain back-compatible for awhile. So
 223+ * of this in 1.17 but we want to remain back-compatible for a while. So
215224 * load up these old global-based things into our update list.
216225 */
217226 protected function getOldGlobalUpdates() {
Index: trunk/phase3/includes/installer/MysqlUpdater.php
@@ -253,7 +253,7 @@
254254 }
255255
256256 protected function doOldLinksUpdate() {
257 - $cl = new ConvertLinks();
 257+ $cl = $this->maintenance->runChild( 'ConvertLinks' );
258258 $cl->execute();
259259 }
260260
@@ -696,7 +696,7 @@
697697 $this->output( "ok\n" );
698698
699699 $this->output( "Migrating old restrictions to new table...\n" );
700 - $task = new UpdateRestrictions();
 700+ $task = $this->maintenance->runChild( 'UpdateRestrictions' );
701701 $task->execute();
702702 }
703703
@@ -719,7 +719,7 @@
720720 "may want to hit Ctrl-C and do this manually with maintenance/\n" .
721721 "populateCategory.php.\n"
722722 );
723 - $task = new PopulateCategory();
 723+ $task = $this->maintenance->runChild( 'PopulateCategory' );
724724 $task->execute();
725725 $this->output( "Done populating category table.\n" );
726726 }
@@ -730,7 +730,7 @@
731731 return;
732732 }
733733
734 - $task = new PopulateParentId();
 734+ $task = $this->maintenance->runChild( 'PopulateParentId' );
735735 $task->execute();
736736 }
737737
@@ -794,7 +794,7 @@
795795 return;
796796 }
797797
798 - $task = new PopulateRevisionLength();
 798+ $task = $this->maintenance->runChild( 'PopulateRevisionLength' );
799799 $task->execute();
800800 }
801801

Follow-up revisions

RevisionCommit summaryAuthorDate
r75738Follow up r75542, in the odd case that Maintenance.php wasn't already loaded.platonides19:07, 31 October 2010
r77953Fix breakage from r75542: FakeMaintenance needs to set at least $mSelf so whe...demon02:42, 7 December 2010

Status & tagging log