Index: trunk/phase3/maintenance/update.php |
— | — | @@ -64,7 +64,7 @@ |
65 | 65 | $shared = $this->hasOption( 'doshared' ); |
66 | 66 | $purge = !$this->hasOption( 'nopurge' ); |
67 | 67 | |
68 | | - $updater = DatabaseUpdater::newForDb( $db, $shared ); |
| 68 | + $updater = DatabaseUpdater::newForDb( $db, $shared, $this ); |
69 | 69 | $updater->doUpdates( $purge ); |
70 | 70 | |
71 | 71 | foreach( $updater->getPostDatabaseUpdateMaintenance() as $maint ) { |
Index: trunk/phase3/maintenance/Maintenance.php |
— | — | @@ -229,6 +229,10 @@ |
230 | 230 | return rtrim( $input ); |
231 | 231 | } |
232 | 232 | |
| 233 | + public function isQuiet() { |
| 234 | + return $this->mQuiet; |
| 235 | + } |
| 236 | + |
233 | 237 | /** |
234 | 238 | * Throw some output to the user. Scripts can call this with no fears, |
235 | 239 | * as we handle all --quiet stuff here |
— | — | @@ -366,7 +370,7 @@ |
367 | 371 | * @param $classFile String: full path of where the child is |
368 | 372 | * @return Maintenance child |
369 | 373 | */ |
370 | | - protected function runChild( $maintClass, $classFile = null ) { |
| 374 | + public function runChild( $maintClass, $classFile = null ) { |
371 | 375 | // If we haven't already specified, kill setup procedures |
372 | 376 | // for child scripts, we've already got a sane environment |
373 | 377 | self::disableSetup(); |
— | — | @@ -1032,3 +1036,10 @@ |
1033 | 1037 | } |
1034 | 1038 | |
1035 | 1039 | } |
| 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 @@ |
38 | 38 | * |
39 | 39 | * @param $db DatabaseBase object to perform updates on |
40 | 40 | * @param $shared bool Whether to perform updates on shared tables |
| 41 | + * @param $maintenance Maintenance Maintenance object which created us |
41 | 42 | * |
42 | 43 | * @TODO @FIXME Make $wgDatabase go away. |
43 | 44 | */ |
44 | | - protected function __construct( DatabaseBase &$db, $shared ) { |
| 45 | + protected function __construct( DatabaseBase &$db, $shared, Maintenance $maintenance = null ) { |
45 | 46 | global $wgDatabase; |
46 | 47 | $wgDatabase = $db; |
47 | 48 | $this->db = $db; |
48 | 49 | $this->shared = $shared; |
| 50 | + if ( $maintenance ) { |
| 51 | + $this->maintenance = $maintenance; |
| 52 | + } else { |
| 53 | + $this->maintenance = new FakeMaintenance; |
| 54 | + } |
49 | 55 | $this->initOldGlobals(); |
50 | 56 | wfRunHooks( 'LoadExtensionSchemaUpdates', array( $this ) ); |
51 | 57 | } |
— | — | @@ -67,11 +73,11 @@ |
68 | 74 | $wgExtModifiedFields = array(); // table, index, dir |
69 | 75 | } |
70 | 76 | |
71 | | - public static function newForDB( &$db, $shared = false ) { |
| 77 | + public static function newForDB( &$db, $shared = false, $maintenance = null ) { |
72 | 78 | $type = $db->getType(); |
73 | 79 | if( in_array( $type, Installer::getDBTypes() ) ) { |
74 | 80 | $class = ucfirst( $type ) . 'Updater'; |
75 | | - return new $class( $db, $shared ); |
| 81 | + return new $class( $db, $shared, $maintenance ); |
76 | 82 | } else { |
77 | 83 | throw new MWException( __METHOD__ . ' called for unsupported $wgDBtype' ); |
78 | 84 | } |
— | — | @@ -93,6 +99,9 @@ |
94 | 100 | * @param $str String: Text to output |
95 | 101 | */ |
96 | 102 | protected function output( $str ) { |
| 103 | + if ( $this->maintenance->isQuiet() ) { |
| 104 | + return; |
| 105 | + } |
97 | 106 | wfOut( $str ); |
98 | 107 | } |
99 | 108 | |
— | — | @@ -210,7 +219,7 @@ |
211 | 220 | /** |
212 | 221 | * Before 1.17, we used to handle updates via stuff like |
213 | 222 | * $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 |
215 | 224 | * load up these old global-based things into our update list. |
216 | 225 | */ |
217 | 226 | protected function getOldGlobalUpdates() { |
Index: trunk/phase3/includes/installer/MysqlUpdater.php |
— | — | @@ -253,7 +253,7 @@ |
254 | 254 | } |
255 | 255 | |
256 | 256 | protected function doOldLinksUpdate() { |
257 | | - $cl = new ConvertLinks(); |
| 257 | + $cl = $this->maintenance->runChild( 'ConvertLinks' ); |
258 | 258 | $cl->execute(); |
259 | 259 | } |
260 | 260 | |
— | — | @@ -696,7 +696,7 @@ |
697 | 697 | $this->output( "ok\n" ); |
698 | 698 | |
699 | 699 | $this->output( "Migrating old restrictions to new table...\n" ); |
700 | | - $task = new UpdateRestrictions(); |
| 700 | + $task = $this->maintenance->runChild( 'UpdateRestrictions' ); |
701 | 701 | $task->execute(); |
702 | 702 | } |
703 | 703 | |
— | — | @@ -719,7 +719,7 @@ |
720 | 720 | "may want to hit Ctrl-C and do this manually with maintenance/\n" . |
721 | 721 | "populateCategory.php.\n" |
722 | 722 | ); |
723 | | - $task = new PopulateCategory(); |
| 723 | + $task = $this->maintenance->runChild( 'PopulateCategory' ); |
724 | 724 | $task->execute(); |
725 | 725 | $this->output( "Done populating category table.\n" ); |
726 | 726 | } |
— | — | @@ -730,7 +730,7 @@ |
731 | 731 | return; |
732 | 732 | } |
733 | 733 | |
734 | | - $task = new PopulateParentId(); |
| 734 | + $task = $this->maintenance->runChild( 'PopulateParentId' ); |
735 | 735 | $task->execute(); |
736 | 736 | } |
737 | 737 | |
— | — | @@ -794,7 +794,7 @@ |
795 | 795 | return; |
796 | 796 | } |
797 | 797 | |
798 | | - $task = new PopulateRevisionLength(); |
| 798 | + $task = $this->maintenance->runChild( 'PopulateRevisionLength' ); |
799 | 799 | $task->execute(); |
800 | 800 | } |
801 | 801 | |