Index: trunk/phase3/includes/installer/Installer.php |
— | — | @@ -235,7 +235,7 @@ |
236 | 236 | } |
237 | 237 | foreach ( $this->dbTypes as $type ) { |
238 | 238 | $installer = $this->getDBInstaller( $type ); |
239 | | - if ( !$installer ) { |
| 239 | + if ( !$installer->isCompiled() ) { |
240 | 240 | continue; |
241 | 241 | } |
242 | 242 | $defaults = $installer->getGlobalDefaults(); |
— | — | @@ -282,11 +282,7 @@ |
283 | 283 | |
284 | 284 | if ( !isset( $this->dbInstallers[$type] ) ) { |
285 | 285 | $class = ucfirst( $type ). 'Installer'; |
286 | | - if ( call_user_func( array( $class, 'isCompiled' ) ) ) { |
287 | | - $this->dbInstallers[$type] = new $class( $this ); |
288 | | - } else { |
289 | | - $this->dbInstallers[$type] = false; |
290 | | - } |
| 286 | + $this->dbInstallers[$type] = new $class( $this ); |
291 | 287 | } |
292 | 288 | return $this->dbInstallers[$type]; |
293 | 289 | } |
— | — | @@ -867,6 +863,7 @@ |
868 | 864 | */ |
869 | 865 | public function performInstallation( $startCB, $endCB ) { |
870 | 866 | $installResults = array(); |
| 867 | + $installer = $this->getDBInstaller(); |
871 | 868 | foreach( $this->getInstallSteps() as $stepObj ) { |
872 | 869 | $step = is_array( $stepObj ) ? $stepObj['name'] : $stepObj; |
873 | 870 | call_user_func_array( $startCB, array( $step ) ); |
— | — | @@ -880,7 +877,7 @@ |
881 | 878 | } else { |
882 | 879 | # Boring implicitly named callback |
883 | 880 | $func = 'install' . ucfirst( $step ); |
884 | | - $status = $this->{$func}(); |
| 881 | + $status = $this->{$func}( $installer ); |
885 | 882 | } |
886 | 883 | call_user_func_array( $endCB, array( $step, $status ) ); |
887 | 884 | $installResults[$step] = $status; |
— | — | @@ -903,10 +900,9 @@ |
904 | 901 | return Status::newGood(); |
905 | 902 | } |
906 | 903 | |
907 | | - public function installDatabase() { |
908 | | - $type = $this->getVar( 'wgDBtype' ); |
909 | | - $installer = $this->getDBInstaller( $type ); |
| 904 | + public function installDatabase( &$installer ) { |
910 | 905 | if(!$installer) { |
| 906 | + $type = $this->getVar( 'wgDBtype' ); |
911 | 907 | $status = Status::newFatal( "config-no-db", $type ); |
912 | 908 | } else { |
913 | 909 | $status = $installer->setupDatabase(); |
— | — | @@ -914,8 +910,7 @@ |
915 | 911 | return $status; |
916 | 912 | } |
917 | 913 | |
918 | | - public function installTables() { |
919 | | - $installer = $this->getDBInstaller(); |
| 914 | + public function installTables( &$installer ) { |
920 | 915 | $status = $installer->createTables(); |
921 | 916 | if( $status->isOK() ) { |
922 | 917 | LBFactory::enableBackend(); |
— | — | @@ -923,8 +918,7 @@ |
924 | 919 | return $status; |
925 | 920 | } |
926 | 921 | |
927 | | - public function installInterwiki() { |
928 | | - $installer = $this->getDBInstaller(); |
| 922 | + public function installInterwiki( &$installer ) { |
929 | 923 | return $installer->populateInterwikiTable(); |
930 | 924 | } |
931 | 925 | |
Index: trunk/phase3/includes/installer/SqliteInstaller.php |
— | — | @@ -10,7 +10,7 @@ |
11 | 11 | return 'sqlite'; |
12 | 12 | } |
13 | 13 | |
14 | | - static function isCompiled() { |
| 14 | + public function isCompiled() { |
15 | 15 | return self::checkExtension( 'pdo_sqlite' ); |
16 | 16 | } |
17 | 17 | |
Index: trunk/phase3/includes/installer/MysqlInstaller.php |
— | — | @@ -34,22 +34,9 @@ |
35 | 35 | |
36 | 36 | function __construct( $parent ) { |
37 | 37 | parent::__construct( $parent ); |
38 | | - |
39 | | - if ( $this->parent->getVar( 'wgDBtype' ) !== $this->getName() ) { |
40 | | - return; |
41 | | - } |
42 | | - |
43 | | - # Add our user callback to installSteps, right before the tables are created. |
44 | | - $callback = array( |
45 | | - array( |
46 | | - 'name' => 'user', |
47 | | - 'callback' => array( &$this, 'setupUser' ), |
48 | | - ) |
49 | | - ); |
50 | | - $this->parent->addInstallStepFollowing( "tables", $callback ); |
51 | 38 | } |
52 | 39 | |
53 | | - static function isCompiled() { |
| 40 | + public function isCompiled() { |
54 | 41 | return self::checkExtension( 'mysql' ); |
55 | 42 | } |
56 | 43 | |
— | — | @@ -379,6 +366,17 @@ |
380 | 367 | return Status::newGood(); |
381 | 368 | } |
382 | 369 | |
| 370 | + public function preInstall() { |
| 371 | + # Add our user callback to installSteps, right before the tables are created. |
| 372 | + $callback = array( |
| 373 | + array( |
| 374 | + 'name' => 'user', |
| 375 | + 'callback' => array( &$this, 'setupUser' ), |
| 376 | + ) |
| 377 | + ); |
| 378 | + $this->parent->addInstallStepFollowing( "tables", $callback ); |
| 379 | + } |
| 380 | + |
383 | 381 | function setupDatabase() { |
384 | 382 | $status = $this->getConnection(); |
385 | 383 | if ( !$status->isOK() ) { |
Index: trunk/phase3/includes/installer/OracleInstaller.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | return 'oracle'; |
21 | 21 | } |
22 | 22 | |
23 | | - static function isCompiled() { |
| 23 | + public function isCompiled() { |
24 | 24 | return self::checkExtension( 'oci8' ); |
25 | 25 | } |
26 | 26 | |
Index: trunk/phase3/includes/installer/PostgresInstaller.php |
— | — | @@ -25,7 +25,7 @@ |
26 | 26 | return 'postgres'; |
27 | 27 | } |
28 | 28 | |
29 | | - static function isCompiled() { |
| 29 | + public function isCompiled() { |
30 | 30 | return self::checkExtension( 'pgsql' ); |
31 | 31 | } |
32 | 32 | |
Index: trunk/phase3/includes/installer/InstallerDBType.php |
— | — | @@ -24,7 +24,7 @@ |
25 | 25 | /** |
26 | 26 | * @return true if the client library is compiled in |
27 | 27 | */ |
28 | | - abstract static function isCompiled(); |
| 28 | + abstract public function isCompiled(); |
29 | 29 | |
30 | 30 | /** |
31 | 31 | * Get an array of MW configuration globals that will be configured by this class. |
— | — | @@ -78,6 +78,13 @@ |
79 | 79 | abstract function getConnection(); |
80 | 80 | |
81 | 81 | /** |
| 82 | + * Allow DB installers a chance to make last-minute changes before installation |
| 83 | + * occurs. This happens before setupDatabase() or createTables() is called, but |
| 84 | + * long after the constructor. Helpful for things like modifying setup steps :) |
| 85 | + */ |
| 86 | + public function preInstall() {} |
| 87 | + |
| 88 | + /** |
82 | 89 | * Create the database and return a Status object indicating success or |
83 | 90 | * failure. |
84 | 91 | * |
— | — | @@ -126,7 +133,7 @@ |
127 | 134 | * Convenience function |
128 | 135 | * Check if a named extension is present |
129 | 136 | */ |
130 | | - static function checkExtension( $name ) { |
| 137 | + protected static function checkExtension( $name ) { |
131 | 138 | wfSuppressWarnings(); |
132 | 139 | $compiled = wfDl( $name ); |
133 | 140 | wfRestoreWarnings(); |