Index: trunk/phase3/includes/installer/DatabaseUpdater.php |
— | — | @@ -31,6 +31,12 @@ |
32 | 32 | protected $extensionUpdates = array(); |
33 | 33 | |
34 | 34 | /** |
| 35 | + * List of extension-provided database updaters |
| 36 | + * @var array |
| 37 | + */ |
| 38 | + protected $extensionUpdaters = array(); |
| 39 | + |
| 40 | + /** |
35 | 41 | * Used to hold schema files during installation process |
36 | 42 | * @var array |
37 | 43 | */ |
— | — | @@ -170,6 +176,17 @@ |
171 | 177 | } |
172 | 178 | |
173 | 179 | /** |
| 180 | + * Add a updater class that will handle extensions DB install/update. |
| 181 | + * This should be called by extensions while executing the |
| 182 | + * LoadExtensionSchemaUpdates hook. |
| 183 | + * |
| 184 | + * @param $updater (string) classname (extends DatabaseUpdater). |
| 185 | + */ |
| 186 | + public function addExtensionUpdater( $updater ) { |
| 187 | + $this->extensionUpdaters[] = $updater; |
| 188 | + } |
| 189 | + |
| 190 | + /** |
174 | 191 | * Convenience wrapper for addExtensionUpdate() when adding a new table (which |
175 | 192 | * is the most common usage of updaters in an extension) |
176 | 193 | * @param $tableName String Name of table to create |
— | — | @@ -205,6 +222,15 @@ |
206 | 223 | return $this->extensionUpdates; |
207 | 224 | } |
208 | 225 | |
| 226 | + /** |
| 227 | + * Get the list of extension-defined updaters |
| 228 | + * |
| 229 | + * @return Array |
| 230 | + */ |
| 231 | + protected function getExtensionUpdaters() { |
| 232 | + return $this->extensionUpdaters; |
| 233 | + } |
| 234 | + |
209 | 235 | public function getPostDatabaseUpdateMaintenance() { |
210 | 236 | return $this->postDatabaseUpdateMaintenance; |
211 | 237 | } |
— | — | @@ -224,6 +250,10 @@ |
225 | 251 | if ( isset( $what['extensions'] ) ) { |
226 | 252 | $this->runUpdates( $this->getOldGlobalUpdates(), false ); |
227 | 253 | $this->runUpdates( $this->getExtensionUpdates(), true ); |
| 254 | + foreach ( $this->getExtensionUpdaters() as $updaterClass ) { |
| 255 | + $eupdater = new $updaterClass(this); |
| 256 | + $eupdater->doUpdates(); |
| 257 | + } |
228 | 258 | } |
229 | 259 | |
230 | 260 | $this->setAppliedUpdates( $wgVersion, $this->updates ); |
Index: trunk/phase3/includes/installer/ExtensionUpdater.php |
— | — | @@ -0,0 +1,16 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class ExtensionUpdater extends DatabaseUpdater { |
| 5 | + |
| 6 | + // overload the constructor, so the init and hooks don't get called |
| 7 | + // while still have all the patching code without duplicating |
| 8 | + public __construct( DatabaseBase &$db, $shared, Maintenance $maintenance = null ) { |
| 9 | + $this->db = $db; |
| 10 | + $this->shared = $shared; |
| 11 | + $this->maintenance = $maintenance; |
| 12 | + } |
| 13 | + |
| 14 | + public function doUpdates() { |
| 15 | + $this->runUpdates( $this->getCoreUpdateList(), false ); |
| 16 | + } |
| 17 | +} |
Property changes on: trunk/phase3/includes/installer/ExtensionUpdater.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 18 | + native |