From a2bbf1023104e6d26fc6debc5c41999b646b7563 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Tue, 7 Sep 2010 20:57:53 +0000 Subject: [PATCH] Per ^demon's comment on r71430: moved doUpgrade() to DatabaseInstaller (did not remove the stub method in Oracle installer) --- includes/installer/DatabaseInstaller.php | 20 ++++++++++++++++-- includes/installer/MysqlInstaller.php | 26 ++---------------------- includes/installer/PostgresInstaller.php | 10 ++++++--- includes/installer/SqliteInstaller.php | 10 --------- 4 files changed, 27 insertions(+), 39 deletions(-) diff --git a/includes/installer/DatabaseInstaller.php b/includes/installer/DatabaseInstaller.php index 099742f6dc..4681d577c8 100644 --- a/includes/installer/DatabaseInstaller.php +++ b/includes/installer/DatabaseInstaller.php @@ -141,14 +141,30 @@ abstract class DatabaseInstaller { * * @return String */ - public abstract function getLocalSettings(); + public abstract function getLocalSettings(); /** * Perform database upgrades * * @return Boolean */ - public abstract function doUpgrade(); + public function doUpgrade() { + # Maintenance scripts like wfGetDB() + LBFactory::enableBackend(); + + $ret = true; + ob_start( array( __CLASS__, 'outputHandler' ) ); + try { + $up = DatabaseUpdater::newForDB( $this->db ); + $up->execute(); + } catch ( MWException $e ) { + echo "\nAn error occured:\n"; + echo $e->getText(); + $ret = false; + } + ob_end_flush(); + return $ret; + } /** * Allow DB installers a chance to make last-minute changes before installation diff --git a/includes/installer/MysqlInstaller.php b/includes/installer/MysqlInstaller.php index 8d483bd5db..3876d1a861 100644 --- a/includes/installer/MysqlInstaller.php +++ b/includes/installer/MysqlInstaller.php @@ -131,6 +131,8 @@ class MysqlInstaller extends DatabaseInstaller { } public function preUpgrade() { + global $wgDBuser, $wgDBpassword; + $status = $this->getConnection(); if ( !$status->isOK() ) { $this->parent->showStatusError( $status ); @@ -178,35 +180,11 @@ class MysqlInstaller extends DatabaseInstaller { $this->parent->showMessage( 'config-mysql-egine-mismatch', $this->getVar( '_MysqlEngine' ), $existingEngine ); $this->setVar( '_MysqlEngine', $existingEngine ); } - } - - /** - * @todo FIXME: this code is just pure crap for compatibility between - * old and new code. - */ - public function doUpgrade() { - global $wgDBuser, $wgDBpassword; - # Some maintenance scripts like wfGetDB() - LBFactory::enableBackend(); # Normal user and password are selected after this step, so for now # just copy these two $wgDBuser = $this->getVar( '_InstallUser' ); $wgDBpassword = $this->getVar( '_InstallPassword' ); - - $ret = true; - - ob_start( array( $this, 'outputHandler' ) ); - try { - $updater = DatabaseUpdater::newForDb( $this->db ); - $updater->doUpdates(); - } catch ( MWException $e ) { - echo "\nAn error occured:\n"; - echo $e->getText(); - $ret = false; - } - ob_end_flush(); - return $ret; } /** diff --git a/includes/installer/PostgresInstaller.php b/includes/installer/PostgresInstaller.php index 48602a7a0e..75ff055ce4 100644 --- a/includes/installer/PostgresInstaller.php +++ b/includes/installer/PostgresInstaller.php @@ -126,8 +126,12 @@ class PostgresInstaller extends DatabaseInstaller { \$wgDBts2schema = \"{$ts2}\";"; } - public function doUpgrade() { - // TODO - return false; + public function preUpgrade() { + global $wgDBuser, $wgDBpassword; + + # Normal user and password are selected after this step, so for now + # just copy these two + $wgDBuser = $this->getVar( '_InstallUser' ); + $wgDBpassword = $this->getVar( '_InstallPassword' ); } } diff --git a/includes/installer/SqliteInstaller.php b/includes/installer/SqliteInstaller.php index a06d4c8f99..5109539b23 100644 --- a/includes/installer/SqliteInstaller.php +++ b/includes/installer/SqliteInstaller.php @@ -170,16 +170,6 @@ class SqliteInstaller extends DatabaseInstaller { return $status; } - public function doUpgrade() { - LBFactory::enableBackend(); - $db = wfGetDB( DB_MASTER ); - ob_start( array( $this, 'outputHandler' ) ); - $updater = DatabaseUpdater::newForDb( $this->db ); - $updater->doUpdates(); - ob_end_flush(); - return true; - } - public function getLocalSettings() { $dir = LocalSettingsGenerator::escapePhpString( $this->getVar( 'wgSQLiteDataDir' ) ); return -- 2.20.1