$dbName = false, $flags = 0,
$schema = self::USE_GLOBAL )
{
-
- global $wgOut, $wgDBmwschema;
- # Can't get a reference if it hasn't been set yet
- if ( !isset( $wgOut ) ) {
- $wgOut = null;
- }
- $this->mFlags = DBO_TRX | $flags;
-
if ( $schema == self::USE_GLOBAL ) {
$this->mSchema = $wgDBmwschema;
} else {
$this->setDB2Option( 'rowcount', 'DB2_ROWCOUNT_PREFETCH_ON',
self::STMT_OPTION );
- $this->open( $server, $user, $password, $dbName );
+ parent::__construct( $server, $user, $password, $dbName, $flags );
}
/**
var $mLastResult = NULL;
var $mAffectedRows = NULL;
- function __construct( $server = false, $user = false, $password = false, $dbName = false,
- $flags = 0 )
- {
- $this->mFlags = $flags;
- $this->open( $server, $user, $password, $dbName );
- }
-
function cascadingDeletes() {
return true;
}
{
$tablePrefix = $tablePrefix == 'get from global' ? $tablePrefix : strtoupper( $tablePrefix );
parent::__construct( $server, $user, $password, $dbName, $flags, $tablePrefix );
- wfRunHooks( 'DatabaseOraclePostInit', array( &$this ) );
+ wfRunHooks( 'DatabaseOraclePostInit', array( $this ) );
}
function getType() {
var $numeric_version = null;
var $mAffectedRows = null;
- function __construct( $server = false, $user = false, $password = false, $dbName = false,
- $flags = 0 )
- {
- $this->mFlags = $flags;
- $this->open( $server, $user, $password, $dbName );
- }
-
function getType() {
return 'postgres';
}
* Parameters $server, $user and $password are not used.
*/
function __construct( $server = false, $user = false, $password = false, $dbName = false, $flags = 0 ) {
- global $wgSharedDB;
- $this->mFlags = $flags;
$this->mName = $dbName;
-
- if( $server ) {
- if ( $this->open( $server, $user, $password, $dbName ) && $wgSharedDB ) {
+ parent::__construct( $server, $user, $password, $dbName, $flags );
+ // parent doesn't open when $server is false, but we can work with $dbName
+ if( !$server && $dbName ) {
+ global $wgSharedDB;
+ if( $this->open( $server, $user, $password, $dbName ) && $wgSharedDB ) {
$this->attachDatabase( $wgSharedDB );
}
}
*
* @var DatabaseBase
*/
- public $db;
+ public $db = null;
/**
* Internal variables for installation.
} else {
$this->db->commit( __METHOD__ );
}
+ // Resume normal operations
+ if( $status->isOk() ) {
+ LBFactory::enableBackend();
+ }
return $status;
}
$this->parserOptions->setExternalLinkTarget( $wgExternalLinkTarget );
}
- /**
- * TODO: document
- *
- * @param $installer DatabaseInstaller
- *
- * @return Status
- */
- public function installTables( DatabaseInstaller &$installer ) {
- $status = $installer->createTables();
-
- if( $status->isOK() ) {
- LBFactory::enableBackend();
- }
-
- return $status;
- }
-
/**
* Exports all wg* variables stored by the installer into global scope.
*/
protected function getInstallSteps( DatabaseInstaller &$installer ) {
$coreInstallSteps = array(
array( 'name' => 'database', 'callback' => array( $installer, 'setupDatabase' ) ),
- array( 'name' => 'tables', 'callback' => array( $this, 'installTables' ) ),
+ array( 'name' => 'tables', 'callback' => array( $installer, 'createTables' ) ),
array( 'name' => 'interwiki', 'callback' => array( $installer, 'populateInterwikiTable' ) ),
array( 'name' => 'secretkey', 'callback' => array( $this, 'generateSecretKey' ) ),
array( 'name' => 'upgradekey', 'callback' => array( $this, 'generateUpgradeKey' ) ),
public function getConnection() {
$status = Status::newGood();
- try {
- $this->db = new DatabaseMysql(
- $this->getVar( 'wgDBserver' ),
- $this->getVar( '_InstallUser' ),
- $this->getVar( '_InstallPassword' ),
- false,
- false,
- 0,
- $this->getVar( 'wgDBprefix' )
- );
+ if( is_null( $this->db ) ) {
+ try {
+ $this->db = new DatabaseMysql(
+ $this->getVar( 'wgDBserver' ),
+ $this->getVar( '_InstallUser' ),
+ $this->getVar( '_InstallPassword' ),
+ false,
+ false,
+ 0,
+ $this->getVar( 'wgDBprefix' )
+ );
+ $status->value = $this->db;
+ } catch ( DBConnectionError $e ) {
+ $status->fatal( 'config-connection-error', $e->getMessage() );
+ }
+ } else {
$status->value = $this->db;
- } catch ( DBConnectionError $e ) {
- $status->fatal( 'config-connection-error', $e->getMessage() );
}
return $status;
}
function getConnection($database = 'template1') {
$status = Status::newGood();
-
- try {
- $this->db = new DatabasePostgres(
- $this->getVar( 'wgDBserver' ),
- $this->getVar( '_InstallUser' ),
- $this->getVar( '_InstallPassword' ),
- $database );
+ if( is_null( $this->db ) ) {
+ try {
+ $this->db = new DatabasePostgres(
+ $this->getVar( 'wgDBserver' ),
+ $this->getVar( '_InstallUser' ),
+ $this->getVar( '_InstallPassword' ),
+ $database );
+ $status->value = $this->db;
+ } catch ( DBConnectionError $e ) {
+ $status->fatal( 'config-connection-error', $e->getMessage() );
+ }
+ } else {
$status->value = $this->db;
- } catch ( DBConnectionError $e ) {
- $status->fatal( 'config-connection-error', $e->getMessage() );
}
return $status;
}
global $wgSQLiteDataDir;
$status = Status::newGood();
- $dir = $this->getVar( 'wgSQLiteDataDir' );
- $dbName = $this->getVar( 'wgDBname' );
-
- try {
- # FIXME: need more sensible constructor parameters, e.g. single associative array
- # Setting globals kind of sucks
- $wgSQLiteDataDir = $dir;
- $this->db = new DatabaseSqlite( false, false, false, $dbName );
+ if( is_null( $this->db ) ) {
+ $dir = $this->getVar( 'wgSQLiteDataDir' );
+ $dbName = $this->getVar( 'wgDBname' );
+
+ try {
+ # FIXME: need more sensible constructor parameters, e.g. single associative array
+ # Setting globals kind of sucks
+ $wgSQLiteDataDir = $dir;
+ $this->db = new DatabaseSqlite( false, false, false, $dbName );
+ $status->value = $this->db;
+ } catch ( DBConnectionError $e ) {
+ $status->fatal( 'config-sqlite-connection-error', $e->getMessage() );
+ }
+ } else {
$status->value = $this->db;
- } catch ( DBConnectionError $e ) {
- $status->fatal( 'config-sqlite-connection-error', $e->getMessage() );
}
return $status;
}