Made DatabaseSqlite::__construct always caller super
authorAaron Schulz <aschulz@wikimedia.org>
Mon, 27 Apr 2015 19:17:52 +0000 (12:17 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Tue, 28 Apr 2015 15:37:21 +0000 (08:37 -0700)
* Also fixed misuse of private mTrxAtomicLevels var

Change-Id: I711508cb3906a5192be1a244a7e511b1720141ca

includes/db/Database.php
includes/db/DatabaseSqlite.php

index d2cac34..5afff91 100644 (file)
@@ -818,14 +818,14 @@ abstract class DatabaseBase implements IDatabase {
                $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;
@@ -2485,7 +2485,7 @@ abstract class DatabaseBase implements IDatabase {
                }
 
                # 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 );
                        }
index ed86bab..2bad711 100644 (file)
@@ -64,16 +64,16 @@ class DatabaseSqlite extends DatabaseBase {
                $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 ) {
@@ -105,8 +105,10 @@ class DatabaseSqlite extends DatabaseBase {
         */
        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 );
        }
 
        /**