*/
protected $extensionUpdates = array();
- /**
- * List of extension-provided database updaters
- * @var array
- */
- protected $extensionUpdaters = array();
-
- /**
- * Used to hold schema files during installation process
- * @var array
- */
- protected $newExtensions = array();
-
/**
* Handle to the database subclass
*
}
$this->maintenance->setDB( $db );
$this->initOldGlobals();
- $this->initIncludedExtensions();
+ $this->loadExtensions();
wfRunHooks( 'LoadExtensionSchemaUpdates', array( $this ) );
}
}
/**
- * Try to include extensions from LocalSettings so their LocalExtensionSchemaChanges hooks can be run
+ * Loads LocalSettings.php, if needed, and initialises everything needed for LoadExtensionSchemaUpdates hook
*/
- private function initIncludedExtensions() {
- global $IP, $wgHooks, $wgAutoloadClasses;
- $ls = file_get_contents( "$IP/LocalSettings.php" );
- if ( $ls === false ) return;
- $matches = array();
- preg_match_all( '/[[:blank:]]*(?:require|include){1}(?:_once)?[[:blank:]]*\([[:blank:]]*"\$IP\/extensions\/([^\/].*)\/\1\.php"[[:blank:]]*\);[[:blank:]]*/i',
- $ls, $matches, PREG_SET_ORDER );
- unset( $ls );
-
- if ( !isset( $wgHooks ) )
- $wgHooks = array();
- if ( !isset( $wgAutoloadClasses ) )
- $wgAutoloadClasses = array();
-
- foreach ( $matches as $match ) {
- include_once ( "$IP/extensions/{$match[1]}/{$match[1]}.php" );
+ private function loadExtensions() {
+ if ( !defined( 'MEDIAWIKI_INSTALL' ) ) {
+ return; // already loaded
}
+ $vars = Installer::getExistingLocalSettings();
+ if ( !$vars ) {
+ return; // no LocalSettings found
+ }
+ if ( !isset( $vars['wgHooks'] ) || !isset( $vars['wgHooks']['LoadExtensionSchemaUpdates'] ) ) {
+ return;
+ }
+ global $wgHooks, $wgAutoloadClasses;
+ $wgHooks['LoadExtensionSchemaUpdates'] = $vars['wgHooks']['LoadExtensionSchemaUpdates'];
+ $wgAutoloadClasses = $wgAutoloadClasses + $vars['wgAutoloadClasses'];
}
/**
$this->extensionUpdates[] = $update;
}
- /**
- * Add a updater class that will handle extensions DB install/update.
- * This should be called by extensions while executing the
- * LoadExtensionSchemaUpdates hook.
- *
- * @param $updater (string) classname (extends DatabaseUpdater).
- */
- public function addExtensionUpdater( $updater ) {
- $this->extensionUpdaters[] = $updater;
- }
-
/**
* Convenience wrapper for addExtensionUpdate() when adding a new table (which
* is the most common usage of updaters in an extension)
$this->extensionUpdates[] = array( 'addTable', $tableName, $sqlPath, true );
}
- /**
- * Add a brand new extension to MediaWiki. Used during the initial install
- * @param $ext String Name of extension
- * @param $sqlPath String Full path to the schema file
- */
- public function addNewExtension( $ext, $sqlPath ) {
- $this->newExtensions[ strtolower( $ext ) ] = $sqlPath;
- }
-
- /**
- * Get the list of extensions that registered a schema with our DB type
- * @return array
- */
- public function getNewExtensions() {
- return $this->newExtensions;
- }
-
/**
* Get the list of extension-defined updates
*
return $this->extensionUpdates;
}
- /**
- * Get the list of extension-defined updaters
- *
- * @return Array
- */
- protected function getExtensionUpdaters() {
- return $this->extensionUpdaters;
- }
-
public function getPostDatabaseUpdateMaintenance() {
return $this->postDatabaseUpdateMaintenance;
}
if ( isset( $what['extensions'] ) ) {
$this->runUpdates( $this->getOldGlobalUpdates(), false );
$this->runUpdates( $this->getExtensionUpdates(), true );
- foreach ( $this->getExtensionUpdaters() as $updaterClass ) {
- $eupdater = new $updaterClass( $this );
- $eupdater->doUpdates();
- }
}
$this->setAppliedUpdates( $wgVersion, $this->updates );