Per ^demon's comment on r71430: moved doUpgrade() to DatabaseInstaller (did not remov...
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Tue, 7 Sep 2010 20:57:53 +0000 (20:57 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Tue, 7 Sep 2010 20:57:53 +0000 (20:57 +0000)
includes/installer/DatabaseInstaller.php
includes/installer/MysqlInstaller.php
includes/installer/PostgresInstaller.php
includes/installer/SqliteInstaller.php

index 099742f..4681d57 100644 (file)
@@ -141,14 +141,30 @@ abstract class DatabaseInstaller {
         * 
         * @return String
         */
         * 
         * @return String
         */
-       public abstract function getLocalSettings();    
+       public abstract function getLocalSettings();
        
        /**
         * Perform database upgrades
         *
         * @return Boolean
         */
        
        /**
         * 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
        
        /**
         * Allow DB installers a chance to make last-minute changes before installation
index 8d483bd..3876d1a 100644 (file)
@@ -131,6 +131,8 @@ class MysqlInstaller extends DatabaseInstaller {
        }
 
        public function preUpgrade() {
        }
 
        public function preUpgrade() {
+               global $wgDBuser, $wgDBpassword;
+
                $status = $this->getConnection();
                if ( !$status->isOK() ) {
                        $this->parent->showStatusError( $status );
                $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 );
                }
                        $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' );
                # 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;
        }
 
        /**
        }
 
        /**
index 48602a7..75ff055 100644 (file)
@@ -126,8 +126,12 @@ class PostgresInstaller extends DatabaseInstaller {
 \$wgDBts2schema      = \"{$ts2}\";";
        }
 
 \$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' );
        }
 }
        }
 }
index a06d4c8..5109539 100644 (file)
@@ -170,16 +170,6 @@ class SqliteInstaller extends DatabaseInstaller {
                return $status;
        }
 
                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
        public function getLocalSettings() {
                $dir = LocalSettingsGenerator::escapePhpString( $this->getVar( 'wgSQLiteDataDir' ) );
                return