Index: trunk/phase3/maintenance/updaters.inc |
— | — | @@ -934,16 +934,16 @@ |
935 | 935 | function do_all_updates( $shared = false, $purge = true ) { |
936 | 936 | global $wgSharedDB, $wgSharedTables, $wgDatabase, $wgDBtype; |
937 | 937 | |
938 | | - wfRunHooks( 'LoadExtensionSchemaUpdates' ); |
| 938 | + $updater = DatabaseUpdater::newForDb( $wgDatabase, $shared ); |
939 | 939 | |
| 940 | + wfRunHooks( 'LoadExtensionSchemaUpdates', array( &$updater ) ); |
| 941 | + |
| 942 | + $updater->doUpdates(); |
| 943 | + |
940 | 944 | if ( $wgDBtype === 'postgres' ) { |
941 | | - do_postgres_updates(); |
942 | 945 | return; |
943 | 946 | } |
944 | 947 | |
945 | | - $up = DatabaseUpdater::newForDb( $wgDatabase, $shared ); |
946 | | - $up->doUpdates(); |
947 | | - |
948 | 948 | wfOut( "Deleting old default messages (this may take a long time!)..." ); |
949 | 949 | if ( !defined( 'MW_NO_SETUP' ) ) { |
950 | 950 | define( 'MW_NO_SETUP', true ); |
Index: trunk/phase3/docs/hooks.txt |
— | — | @@ -1031,8 +1031,8 @@ |
1032 | 1032 | 'ListDefinedTags': When trying to find all defined tags. |
1033 | 1033 | &$tags: The list of tags. |
1034 | 1034 | |
1035 | | -'LoadExtensionSchemaUpdates': called by maintenance/updaters.inc when upgrading |
1036 | | -database schema |
| 1035 | +'LoadExtensionSchemaUpdates': called during database installation and updates |
| 1036 | +&updater: A DatabaseUpdater subclass |
1037 | 1037 | |
1038 | 1038 | 'LocalFile::getHistory': called before file history query performed |
1039 | 1039 | $file: the file |
Index: trunk/phase3/includes/installer/DatabaseUpdater.php |
— | — | @@ -26,17 +26,17 @@ |
27 | 27 | } |
28 | 28 | |
29 | 29 | public static function newForDB( $db, $shared ) { |
30 | | - switch( $db->getType() ) { |
31 | | - case 'mysql': |
32 | | - case 'sqlite': |
33 | | - case 'oracle': |
34 | | - $class = ucfirst( $db->getType() ) . 'Updater'; |
35 | | - return new $class( $db, $shared ); |
36 | | - default: |
37 | | - throw new MWException( __METHOD__ . ' called for unsupported $wgDBtype' ); |
| 30 | + $type = $db->getType(); |
| 31 | + if( in_array( $type, Installer::getDBTypes() ) ) { |
| 32 | + $class = ucfirst( $type ) . 'Updater'; |
| 33 | + return new $class( $db, $shared ); |
| 34 | + } else { |
| 35 | + throw new MWException( __METHOD__ . ' called for unsupported $wgDBtype' ); |
38 | 36 | } |
39 | 37 | } |
40 | 38 | |
| 39 | + public function getDB() { return $this->db; } |
| 40 | + |
41 | 41 | public function doUpdates() { |
42 | 42 | global $IP, $wgVersion; |
43 | 43 | require_once( "$IP/maintenance/updaters.inc" ); |
Index: trunk/phase3/includes/installer/PostgresUpdater.php |
— | — | @@ -0,0 +1,23 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Class for handling updates to Postgres databases. |
| 6 | + * |
| 7 | + * @TODO @FIXME - Postgres should use sequential updates like Mysql, Sqlite |
| 8 | + * and everybody else. It never got refactored like it should've. For now, |
| 9 | + * just wrap the old do_postgres_updates() in this class so we can clean up |
| 10 | + * the higher-level stuff. |
| 11 | + * |
| 12 | + * @ingroup Deployment |
| 13 | + * @since 1.17 |
| 14 | + */ |
| 15 | + |
| 16 | +class PostgresUpdater extends Updater { |
| 17 | + protected function getCoreUpdateList() { |
| 18 | + return array(); |
| 19 | + } |
| 20 | + |
| 21 | + public function doUpdates() { |
| 22 | + do_postgres_updates(); |
| 23 | + } |
| 24 | +} |
Property changes on: trunk/phase3/includes/installer/PostgresUpdater.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 25 | + native |
Index: trunk/phase3/includes/installer/Installer.php |
— | — | @@ -61,7 +61,7 @@ |
62 | 62 | * |
63 | 63 | * @var array |
64 | 64 | */ |
65 | | - protected $dbTypes = array( |
| 65 | + protected static $dbTypes = array( |
66 | 66 | 'mysql', |
67 | 67 | 'postgres', |
68 | 68 | 'sqlite', |
— | — | @@ -118,8 +118,8 @@ |
119 | 119 | /** |
120 | 120 | * Get a list of known DB types. |
121 | 121 | */ |
122 | | - public function getDBTypes() { |
123 | | - return $this->dbTypes; |
| 122 | + public static function getDBTypes() { |
| 123 | + return self::$dbTypes; |
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
— | — | @@ -416,7 +416,7 @@ |
417 | 417 | $goodNames = array(); |
418 | 418 | $allNames = array(); |
419 | 419 | |
420 | | - foreach ( $this->dbTypes as $name ) { |
| 420 | + foreach ( self::getDBTypes() as $name ) { |
421 | 421 | $db = $this->getDBInstaller( $name ); |
422 | 422 | $readableName = wfMsg( 'config-type-' . $name ); |
423 | 423 | |
Index: trunk/phase3/includes/installer/CoreInstaller.php |
— | — | @@ -200,7 +200,7 @@ |
201 | 201 | $this->settings[$var] = $GLOBALS[$var]; |
202 | 202 | } |
203 | 203 | |
204 | | - foreach ( $this->dbTypes as $type ) { |
| 204 | + foreach ( self::getDBTypes() as $type ) { |
205 | 205 | $installer = $this->getDBInstaller( $type ); |
206 | 206 | |
207 | 207 | if ( !$installer->isCompiled() ) { |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -437,6 +437,7 @@ |
438 | 438 | 'MysqlInstaller' => 'includes/installer/MysqlInstaller.php', |
439 | 439 | 'MysqlUpdater' => 'includes/installer/MysqlUpdater.php', |
440 | 440 | 'PostgresInstaller' => 'includes/installer/PostgresInstaller.php', |
| 441 | + 'PostgresUpdater' => 'includes/installer/PostgresUpdater.php', |
441 | 442 | 'SqliteInstaller' => 'includes/installer/SqliteInstaller.php', |
442 | 443 | 'SqliteUpdater' => 'includes/installer/SqliteUpdater.php', |
443 | 444 | 'OracleInstaller' => 'includes/installer/OracleInstaller.php', |