*
* @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 ) );
}
$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' );
}
* @param $str String: Text to output
*/
protected function output( $str ) {
+ if ( $this->maintenance->isQuiet() ) {
+ return;
+ }
wfOut( $str );
}
/**
* 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() {
}
protected function doOldLinksUpdate() {
- $cl = new ConvertLinks();
+ $cl = $this->maintenance->runChild( 'ConvertLinks' );
$cl->execute();
}
$this->output( "ok\n" );
$this->output( "Migrating old restrictions to new table...\n" );
- $task = new UpdateRestrictions();
+ $task = $this->maintenance->runChild( 'UpdateRestrictions' );
$task->execute();
}
"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" );
}
return;
}
- $task = new PopulateParentId();
+ $task = $this->maintenance->runChild( 'PopulateParentId' );
$task->execute();
}
return;
}
- $task = new PopulateRevisionLength();
+ $task = $this->maintenance->runChild( 'PopulateRevisionLength' );
$task->execute();
}
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
* @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();
}
}
+
+class FakeMaintenance extends Maintenance {
+ public function execute() {
+ return;
+ }
+}
+
$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 ) {