}
foreach ( $this->dbTypes as $type ) {
$installer = $this->getDBInstaller( $type );
- if ( !$installer ) {
+ if ( !$installer->isCompiled() ) {
continue;
}
$defaults = $installer->getGlobalDefaults();
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];
}
*/
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 ) );
} 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;
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();
return $status;
}
- public function installTables() {
- $installer = $this->getDBInstaller();
+ public function installTables( &$installer ) {
$status = $installer->createTables();
if( $status->isOK() ) {
LBFactory::enableBackend();
return $status;
}
- public function installInterwiki() {
- $installer = $this->getDBInstaller();
+ public function installInterwiki( &$installer ) {
return $installer->populateInterwikiTable();
}
/**
* @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.
*/
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.
* Convenience function
* Check if a named extension is present
*/
- static function checkExtension( $name ) {
+ protected static function checkExtension( $name ) {
wfSuppressWarnings();
$compiled = wfDl( $name );
wfRestoreWarnings();
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' );
}
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() ) {