Index: trunk/phase3/includes/db/DatabaseOracle.php |
— | — | @@ -182,7 +182,7 @@ |
183 | 183 | { |
184 | 184 | $tablePrefix = $tablePrefix == 'get from global' ? $tablePrefix : strtoupper( $tablePrefix ); |
185 | 185 | parent::__construct( $server, $user, $password, $dbName, $flags, $tablePrefix ); |
186 | | - wfRunHooks( 'DatabaseOraclePostInit', array( &$this ) ); |
| 186 | + wfRunHooks( 'DatabaseOraclePostInit', array( $this ) ); |
187 | 187 | } |
188 | 188 | |
189 | 189 | function getType() { |
Index: trunk/phase3/includes/db/DatabasePostgres.php |
— | — | @@ -100,13 +100,6 @@ |
101 | 101 | var $numeric_version = null; |
102 | 102 | var $mAffectedRows = null; |
103 | 103 | |
104 | | - function __construct( $server = false, $user = false, $password = false, $dbName = false, |
105 | | - $flags = 0 ) |
106 | | - { |
107 | | - $this->mFlags = $flags; |
108 | | - $this->open( $server, $user, $password, $dbName ); |
109 | | - } |
110 | | - |
111 | 104 | function getType() { |
112 | 105 | return 'postgres'; |
113 | 106 | } |
Index: trunk/phase3/includes/db/DatabaseIbm_db2.php |
— | — | @@ -264,14 +264,6 @@ |
265 | 265 | $dbName = false, $flags = 0, |
266 | 266 | $schema = self::USE_GLOBAL ) |
267 | 267 | { |
268 | | - |
269 | | - global $wgOut, $wgDBmwschema; |
270 | | - # Can't get a reference if it hasn't been set yet |
271 | | - if ( !isset( $wgOut ) ) { |
272 | | - $wgOut = null; |
273 | | - } |
274 | | - $this->mFlags = DBO_TRX | $flags; |
275 | | - |
276 | 268 | if ( $schema == self::USE_GLOBAL ) { |
277 | 269 | $this->mSchema = $wgDBmwschema; |
278 | 270 | } else { |
— | — | @@ -286,7 +278,7 @@ |
287 | 279 | $this->setDB2Option( 'rowcount', 'DB2_ROWCOUNT_PREFETCH_ON', |
288 | 280 | self::STMT_OPTION ); |
289 | 281 | |
290 | | - $this->open( $server, $user, $password, $dbName ); |
| 282 | + parent::__construct( $server, $user, $password, $dbName, $flags ); |
291 | 283 | } |
292 | 284 | |
293 | 285 | /** |
Index: trunk/phase3/includes/db/DatabaseMssql.php |
— | — | @@ -17,13 +17,6 @@ |
18 | 18 | var $mLastResult = NULL; |
19 | 19 | var $mAffectedRows = NULL; |
20 | 20 | |
21 | | - function __construct( $server = false, $user = false, $password = false, $dbName = false, |
22 | | - $flags = 0 ) |
23 | | - { |
24 | | - $this->mFlags = $flags; |
25 | | - $this->open( $server, $user, $password, $dbName ); |
26 | | - } |
27 | | - |
28 | 21 | function cascadingDeletes() { |
29 | 22 | return true; |
30 | 23 | } |
Index: trunk/phase3/includes/db/DatabaseSqlite.php |
— | — | @@ -24,12 +24,12 @@ |
25 | 25 | * Parameters $server, $user and $password are not used. |
26 | 26 | */ |
27 | 27 | function __construct( $server = false, $user = false, $password = false, $dbName = false, $flags = 0 ) { |
28 | | - global $wgSharedDB; |
29 | | - $this->mFlags = $flags; |
30 | 28 | $this->mName = $dbName; |
31 | | - |
32 | | - if( $server ) { |
33 | | - if ( $this->open( $server, $user, $password, $dbName ) && $wgSharedDB ) { |
| 29 | + parent::__construct( $server, $user, $password, $dbName, $flags ); |
| 30 | + // parent doesn't open when $server is false, but we can work with $dbName |
| 31 | + if( !$server && $dbName ) { |
| 32 | + global $wgSharedDB; |
| 33 | + if( $this->open( $server, $user, $password, $dbName ) && $wgSharedDB ) { |
34 | 34 | $this->attachDatabase( $wgSharedDB ); |
35 | 35 | } |
36 | 36 | } |
Index: trunk/phase3/includes/installer/Installer.php |
— | — | @@ -556,23 +556,6 @@ |
557 | 557 | } |
558 | 558 | |
559 | 559 | /** |
560 | | - * TODO: document |
561 | | - * |
562 | | - * @param $installer DatabaseInstaller |
563 | | - * |
564 | | - * @return Status |
565 | | - */ |
566 | | - public function installTables( DatabaseInstaller &$installer ) { |
567 | | - $status = $installer->createTables(); |
568 | | - |
569 | | - if( $status->isOK() ) { |
570 | | - LBFactory::enableBackend(); |
571 | | - } |
572 | | - |
573 | | - return $status; |
574 | | - } |
575 | | - |
576 | | - /** |
577 | 560 | * Exports all wg* variables stored by the installer into global scope. |
578 | 561 | */ |
579 | 562 | public function exportVars() { |
— | — | @@ -1222,7 +1205,7 @@ |
1223 | 1206 | protected function getInstallSteps( DatabaseInstaller &$installer ) { |
1224 | 1207 | $coreInstallSteps = array( |
1225 | 1208 | array( 'name' => 'database', 'callback' => array( $installer, 'setupDatabase' ) ), |
1226 | | - array( 'name' => 'tables', 'callback' => array( $this, 'installTables' ) ), |
| 1209 | + array( 'name' => 'tables', 'callback' => array( $installer, 'createTables' ) ), |
1227 | 1210 | array( 'name' => 'interwiki', 'callback' => array( $installer, 'populateInterwikiTable' ) ), |
1228 | 1211 | array( 'name' => 'secretkey', 'callback' => array( $this, 'generateSecretKey' ) ), |
1229 | 1212 | array( 'name' => 'upgradekey', 'callback' => array( $this, 'generateUpgradeKey' ) ), |
Index: trunk/phase3/includes/installer/SqliteInstaller.php |
— | — | @@ -93,17 +93,21 @@ |
94 | 94 | global $wgSQLiteDataDir; |
95 | 95 | |
96 | 96 | $status = Status::newGood(); |
97 | | - $dir = $this->getVar( 'wgSQLiteDataDir' ); |
98 | | - $dbName = $this->getVar( 'wgDBname' ); |
| 97 | + if( is_null( $this->db ) ) { |
| 98 | + $dir = $this->getVar( 'wgSQLiteDataDir' ); |
| 99 | + $dbName = $this->getVar( 'wgDBname' ); |
99 | 100 | |
100 | | - try { |
101 | | - # FIXME: need more sensible constructor parameters, e.g. single associative array |
102 | | - # Setting globals kind of sucks |
103 | | - $wgSQLiteDataDir = $dir; |
104 | | - $this->db = new DatabaseSqlite( false, false, false, $dbName ); |
| 101 | + try { |
| 102 | + # FIXME: need more sensible constructor parameters, e.g. single associative array |
| 103 | + # Setting globals kind of sucks |
| 104 | + $wgSQLiteDataDir = $dir; |
| 105 | + $this->db = new DatabaseSqlite( false, false, false, $dbName ); |
| 106 | + $status->value = $this->db; |
| 107 | + } catch ( DBConnectionError $e ) { |
| 108 | + $status->fatal( 'config-sqlite-connection-error', $e->getMessage() ); |
| 109 | + } |
| 110 | + } else { |
105 | 111 | $status->value = $this->db; |
106 | | - } catch ( DBConnectionError $e ) { |
107 | | - $status->fatal( 'config-sqlite-connection-error', $e->getMessage() ); |
108 | 112 | } |
109 | 113 | return $status; |
110 | 114 | } |
Index: trunk/phase3/includes/installer/DatabaseInstaller.php |
— | — | @@ -28,7 +28,7 @@ |
29 | 29 | * |
30 | 30 | * @var DatabaseBase |
31 | 31 | */ |
32 | | - public $db; |
| 32 | + public $db = null; |
33 | 33 | |
34 | 34 | /** |
35 | 35 | * Internal variables for installation. |
— | — | @@ -140,6 +140,10 @@ |
141 | 141 | } else { |
142 | 142 | $this->db->commit( __METHOD__ ); |
143 | 143 | } |
| 144 | + // Resume normal operations |
| 145 | + if( $status->isOk() ) { |
| 146 | + LBFactory::enableBackend(); |
| 147 | + } |
144 | 148 | return $status; |
145 | 149 | } |
146 | 150 | |
Index: trunk/phase3/includes/installer/MysqlInstaller.php |
— | — | @@ -113,19 +113,23 @@ |
114 | 114 | |
115 | 115 | public function getConnection() { |
116 | 116 | $status = Status::newGood(); |
117 | | - try { |
118 | | - $this->db = new DatabaseMysql( |
119 | | - $this->getVar( 'wgDBserver' ), |
120 | | - $this->getVar( '_InstallUser' ), |
121 | | - $this->getVar( '_InstallPassword' ), |
122 | | - false, |
123 | | - false, |
124 | | - 0, |
125 | | - $this->getVar( 'wgDBprefix' ) |
126 | | - ); |
| 117 | + if( is_null( $this->db ) ) { |
| 118 | + try { |
| 119 | + $this->db = new DatabaseMysql( |
| 120 | + $this->getVar( 'wgDBserver' ), |
| 121 | + $this->getVar( '_InstallUser' ), |
| 122 | + $this->getVar( '_InstallPassword' ), |
| 123 | + false, |
| 124 | + false, |
| 125 | + 0, |
| 126 | + $this->getVar( 'wgDBprefix' ) |
| 127 | + ); |
| 128 | + $status->value = $this->db; |
| 129 | + } catch ( DBConnectionError $e ) { |
| 130 | + $status->fatal( 'config-connection-error', $e->getMessage() ); |
| 131 | + } |
| 132 | + } else { |
127 | 133 | $status->value = $this->db; |
128 | | - } catch ( DBConnectionError $e ) { |
129 | | - $status->fatal( 'config-connection-error', $e->getMessage() ); |
130 | 134 | } |
131 | 135 | return $status; |
132 | 136 | } |
Index: trunk/phase3/includes/installer/PostgresInstaller.php |
— | — | @@ -100,16 +100,19 @@ |
101 | 101 | |
102 | 102 | function getConnection($database = 'template1') { |
103 | 103 | $status = Status::newGood(); |
104 | | - |
105 | | - try { |
106 | | - $this->db = new DatabasePostgres( |
107 | | - $this->getVar( 'wgDBserver' ), |
108 | | - $this->getVar( '_InstallUser' ), |
109 | | - $this->getVar( '_InstallPassword' ), |
110 | | - $database ); |
| 104 | + if( is_null( $this->db ) ) { |
| 105 | + try { |
| 106 | + $this->db = new DatabasePostgres( |
| 107 | + $this->getVar( 'wgDBserver' ), |
| 108 | + $this->getVar( '_InstallUser' ), |
| 109 | + $this->getVar( '_InstallPassword' ), |
| 110 | + $database ); |
| 111 | + $status->value = $this->db; |
| 112 | + } catch ( DBConnectionError $e ) { |
| 113 | + $status->fatal( 'config-connection-error', $e->getMessage() ); |
| 114 | + } |
| 115 | + } else { |
111 | 116 | $status->value = $this->db; |
112 | | - } catch ( DBConnectionError $e ) { |
113 | | - $status->fatal( 'config-connection-error', $e->getMessage() ); |
114 | 117 | } |
115 | 118 | return $status; |
116 | 119 | } |