From: Jure Kajzer Date: Wed, 1 Jun 2011 15:15:24 +0000 (+0000) Subject: * suggestion for ExtensionUpdater that would handle DB install/update of extension... X-Git-Tag: 1.31.0-rc.0~29803 X-Git-Url: http://git.cyclocoop.org/%22%20%20.%20generer_url_ecrire%28%22mots_tous%22%29%20.%20%22?a=commitdiff_plain;h=b2461ec96a8d92f06f6761a7869a9f79ec0bfa95;p=lhc%2Fweb%2Fwiklou.git * suggestion for ExtensionUpdater that would handle DB install/update of extension from DatabaseUpdater * could also generate default code for LocalSettingsGenerator * revert if silly :D --- diff --git a/includes/installer/DatabaseUpdater.php b/includes/installer/DatabaseUpdater.php index bc55ccea6f..3a4c716c55 100644 --- a/includes/installer/DatabaseUpdater.php +++ b/includes/installer/DatabaseUpdater.php @@ -30,6 +30,12 @@ abstract class DatabaseUpdater { */ protected $extensionUpdates = array(); + /** + * List of extension-provided database updaters + * @var array + */ + protected $extensionUpdaters = array(); + /** * Used to hold schema files during installation process * @var array @@ -169,6 +175,17 @@ abstract class DatabaseUpdater { $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) @@ -205,6 +222,15 @@ abstract class DatabaseUpdater { return $this->extensionUpdates; } + /** + * Get the list of extension-defined updaters + * + * @return Array + */ + protected function getExtensionUpdaters() { + return $this->extensionUpdaters; + } + public function getPostDatabaseUpdateMaintenance() { return $this->postDatabaseUpdateMaintenance; } @@ -224,6 +250,10 @@ abstract class DatabaseUpdater { 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 ); diff --git a/includes/installer/ExtensionUpdater.php b/includes/installer/ExtensionUpdater.php new file mode 100644 index 0000000000..59404579b6 --- /dev/null +++ b/includes/installer/ExtensionUpdater.php @@ -0,0 +1,16 @@ +db = $db; + $this->shared = $shared; + $this->maintenance = $maintenance; + } + + public function doUpdates() { + $this->runUpdates( $this->getCoreUpdateList(), false ); + } +}