Partial revert r69128: go back to making isCompiled() an instance method rather than...
authorChad Horohoe <demon@users.mediawiki.org>
Wed, 7 Jul 2010 13:52:05 +0000 (13:52 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Wed, 7 Jul 2010 13:52:05 +0000 (13:52 +0000)
includes/installer/Installer.php
includes/installer/InstallerDBType.php
includes/installer/MysqlInstaller.php
includes/installer/OracleInstaller.php
includes/installer/PostgresInstaller.php
includes/installer/SqliteInstaller.php

index 7c44ddb..9ec3c42 100644 (file)
@@ -235,7 +235,7 @@ abstract class Installer {
                }
                foreach ( $this->dbTypes as $type ) {
                        $installer = $this->getDBInstaller( $type );
-                       if ( !$installer ) {
+                       if ( !$installer->isCompiled() ) {
                                continue;
                        }
                        $defaults = $installer->getGlobalDefaults();
@@ -282,11 +282,7 @@ abstract class Installer {
 
                if ( !isset( $this->dbInstallers[$type] ) ) {
                        $class = ucfirst( $type ). 'Installer';
-                       if ( call_user_func( array( $class, 'isCompiled' ) ) ) {
-                               $this->dbInstallers[$type] = new $class( $this );
-                       } else {
-                               $this->dbInstallers[$type] = false;
-                       }
+                       $this->dbInstallers[$type] = new $class( $this );
                }
                return $this->dbInstallers[$type];
        }
@@ -867,6 +863,7 @@ abstract class Installer {
         */
        public function performInstallation( $startCB, $endCB ) {
                $installResults = array();
+               $installer = $this->getDBInstaller();
                foreach( $this->getInstallSteps() as $stepObj ) {
                        $step = is_array( $stepObj ) ? $stepObj['name'] : $stepObj;
                        call_user_func_array( $startCB, array( $step ) );
@@ -880,7 +877,7 @@ abstract class Installer {
                        } else {
                                # Boring implicitly named callback
                                $func = 'install' . ucfirst( $step );
-                               $status = $this->{$func}();
+                               $status = $this->{$func}( $installer );
                        }
                        call_user_func_array( $endCB, array( $step, $status ) );
                        $installResults[$step] = $status;
@@ -903,10 +900,9 @@ abstract class Installer {
                return Status::newGood();
        }
 
-       public function installDatabase() {
-               $type = $this->getVar( 'wgDBtype' );
-               $installer = $this->getDBInstaller( $type );
+       public function installDatabase( &$installer ) {
                if(!$installer) {
+                       $type = $this->getVar( 'wgDBtype' );
                        $status = Status::newFatal( "config-no-db", $type );
                } else {
                        $status = $installer->setupDatabase();
@@ -914,8 +910,7 @@ abstract class Installer {
                return $status;
        }
 
-       public function installTables() {
-               $installer = $this->getDBInstaller();
+       public function installTables( &$installer ) {
                $status = $installer->createTables();
                if( $status->isOK() ) {
                        LBFactory::enableBackend();
@@ -923,8 +918,7 @@ abstract class Installer {
                return $status;
        }
 
-       public function installInterwiki() {
-               $installer = $this->getDBInstaller();
+       public function installInterwiki( &$installer ) {
                return $installer->populateInterwikiTable();
        }
 
index a37110e..0081612 100644 (file)
@@ -24,7 +24,7 @@ abstract class InstallerDBType {
        /**
         * @return true if the client library is compiled in
         */
-       abstract static function isCompiled();
+       abstract public function isCompiled();
 
        /**
         * Get an array of MW configuration globals that will be configured by this class.
@@ -77,6 +77,13 @@ abstract class InstallerDBType {
         */
        abstract function getConnection();
 
+       /**
+        * Allow DB installers a chance to make last-minute changes before installation
+        * occurs. This happens before setupDatabase() or createTables() is called, but
+        * long after the constructor. Helpful for things like modifying setup steps :)
+        */
+       public function preInstall() {}
+
        /**
         * Create the database and return a Status object indicating success or
         * failure.
@@ -126,7 +133,7 @@ abstract class InstallerDBType {
         * Convenience function
         * Check if a named extension is present
         */
-       static function checkExtension( $name ) {
+       protected static function checkExtension( $name ) {
                wfSuppressWarnings();
                $compiled = wfDl( $name );
                wfRestoreWarnings();
index 348e716..e1c6706 100644 (file)
@@ -34,22 +34,9 @@ class MysqlInstaller extends InstallerDBType {
 
        function __construct( $parent ) {
                parent::__construct( $parent );
-
-               if ( $this->parent->getVar( 'wgDBtype' ) !== $this->getName() ) {
-                       return;
-               }
-
-               # Add our user callback to installSteps, right before the tables are created.
-               $callback = array(
-                       array(
-                               'name' => 'user',
-                               'callback' => array( &$this, 'setupUser' ),
-                       )
-               );
-               $this->parent->addInstallStepFollowing( "tables", $callback );
        }
 
-       static function isCompiled() {
+       public function isCompiled() {
                return self::checkExtension( 'mysql' );
        }
 
@@ -379,6 +366,17 @@ class MysqlInstaller extends InstallerDBType {
                return Status::newGood();
        }
 
+       public function preInstall() {
+               # Add our user callback to installSteps, right before the tables are created.
+               $callback = array(
+                       array(
+                               'name' => 'user',
+                               'callback' => array( &$this, 'setupUser' ),
+                       )
+               );
+               $this->parent->addInstallStepFollowing( "tables", $callback );
+       }
+
        function setupDatabase() {
                $status = $this->getConnection();
                if ( !$status->isOK() ) {
index a6cc135..ba3a5ca 100644 (file)
@@ -19,7 +19,7 @@ class OracleInstaller extends InstallerDBType {
                return 'oracle';
        }
 
-       static function isCompiled() {
+       public function isCompiled() {
                return self::checkExtension( 'oci8' );
        }
 
index 65d4116..859e3fb 100644 (file)
@@ -25,7 +25,7 @@ class PostgresInstaller extends InstallerDBType {
                return 'postgres';
        }
 
-       static function isCompiled() {
+       public function isCompiled() {
                return self::checkExtension( 'pgsql' );
        }
 
index 86c5a16..9edc7e1 100644 (file)
@@ -10,7 +10,7 @@ class SqliteInstaller extends InstallerDBType {
                return 'sqlite';
        }
 
-       static function isCompiled() {
+       public function isCompiled() {
                return self::checkExtension( 'pdo_sqlite' );
        }