http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89263
Revision: 89263
Author: freakolowsky
Date: 2011-06-01 15:15:24 +0000 (Wed, 01 Jun 2011)
Log Message:
-----------
* suggestion for ExtensionUpdater that would handle DB install/update of
extension from DatabaseUpdater
* could also generate default code for LocalSettingsGenerator
* revert if silly :D
Modified Paths:
--------------
trunk/phase3/includes/installer/DatabaseUpdater.php
Added Paths:
-----------
trunk/phase3/includes/installer/ExtensionUpdater.php
Modified: trunk/phase3/includes/installer/DatabaseUpdater.php
===================================================================
--- trunk/phase3/includes/installer/DatabaseUpdater.php 2011-06-01 14:18:12 UTC
(rev 89262)
+++ trunk/phase3/includes/installer/DatabaseUpdater.php 2011-06-01 15:15:24 UTC
(rev 89263)
@@ -31,6 +31,12 @@
protected $extensionUpdates = array();
/**
+ * List of extension-provided database updaters
+ * @var array
+ */
+ protected $extensionUpdaters = array();
+
+ /**
* Used to hold schema files during installation process
* @var array
*/
@@ -170,6 +176,17 @@
}
/**
+ * 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)
* @param $tableName String Name of table to create
@@ -205,6 +222,15 @@
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 @@
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 );
Added: trunk/phase3/includes/installer/ExtensionUpdater.php
===================================================================
--- trunk/phase3/includes/installer/ExtensionUpdater.php
(rev 0)
+++ trunk/phase3/includes/installer/ExtensionUpdater.php 2011-06-01
15:15:24 UTC (rev 89263)
@@ -0,0 +1,16 @@
+<?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 );
+ }
+}
Property changes on: trunk/phase3/includes/installer/ExtensionUpdater.php
___________________________________________________________________
Added: svn:eol-style
+ native
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs