$this->mSessionVars = $params['variables'];
/** Get the default table prefix*/
- if ( $tablePrefix == 'get from global' ) {
+ if ( $tablePrefix === 'get from global' ) {
$this->mTablePrefix = $wgDBprefix;
} else {
$this->mTablePrefix = $tablePrefix;
}
/** Get the database schema*/
- if ( $schema == 'get from global' ) {
+ if ( $schema === 'get from global' ) {
$this->mSchema = $wgDBmwschema;
} else {
$this->mSchema = $schema;
}
# Quote $schema and merge it with the table name if needed
- if ( $schema !== null ) {
+ if ( strlen( $schema ) ) {
if ( $format == 'quoted' && !$this->isQuotedIdentifier( $schema ) ) {
$schema = $this->addIdentifierQuotes( $schema );
}
$this->dbDir = isset( $p['dbDirectory'] ) ? $p['dbDirectory'] : $wgSQLiteDataDir;
if ( isset( $p['dbFilePath'] ) ) {
- $this->mFlags = isset( $p['flags'] ) ? $p['flags'] : 0;
- // Standalone .sqlite file mode
+ parent::__construct( $p );
+ // Standalone .sqlite file mode.
+ // Super doesn't open when $user is false, but we can work with $dbName,
+ // which is derived from the file path in this case.
$this->openFile( $p['dbFilePath'] );
- // @FIXME: clean up base constructor so this can call super instead
- $this->mTrxAtomicLevels = new SplStack;
} else {
$this->mDBname = $p['dbname'];
- // Stock wiki mode using standard file names per DB
+ // Stock wiki mode using standard file names per DB.
parent::__construct( $p );
- // parent doesn't open when $user is false, but we can work with $dbName
+ // Super doesn't open when $user is false, but we can work with $dbName
if ( $p['dbname'] && !$this->isOpen() ) {
if ( $this->open( $p['host'], $p['user'], $p['password'], $p['dbname'] ) ) {
if ( $wgSharedDB ) {
*/
public static function newStandaloneInstance( $filename, array $p = array() ) {
$p['dbFilePath'] = $filename;
+ $p['schema'] = false;
+ $p['tablePrefix'] = '';
- return new self( $p );
+ return DatabaseBase::factory( 'sqlite', $p );
}
/**