*/
protected $extensionUpdates = array();
+ /**
+ * List of extension-provided database updaters
+ * @var array
+ */
+ protected $extensionUpdaters = array();
+
/**
* Used to hold schema files during installation process
* @var array
$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)
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 );
--- /dev/null
+<?php
+
+class ExtensionUpdater extends DatabaseUpdater {
+
+ // overload the constructor, so the init and hooks don't get called
+ // while still have all the patching code without duplicating
+ public __construct( DatabaseBase &$db, $shared, Maintenance $maintenance = null ) {
+ $this->db = $db;
+ $this->shared = $shared;
+ $this->maintenance = $maintenance;
+ }
+
+ public function doUpdates() {
+ $this->runUpdates( $this->getCoreUpdateList(), false );
+ }
+}