Start of bug 24853, killing off 'functional' parts of failfunction code. Seems when...
[lhc/web/wiklou.git] / includes / db / DatabaseSqlite.php
index 95c3db6..1313252 100644 (file)
@@ -25,7 +25,6 @@ class DatabaseSqlite extends DatabaseBase {
         */
        function __construct( $server = false, $user = false, $password = false, $dbName = false, $failFunction = false, $flags = 0 ) {
                global $wgSharedDB;
-               $this->mFailFunction = $failFunction;
                $this->mFlags = $flags;
                $this->mName = $dbName;
 
@@ -34,16 +33,6 @@ class DatabaseSqlite extends DatabaseBase {
                }
        }
 
-       /**
-        * Serialization handler, see http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.sleep
-        * for details. Instances of this class sometimes get serialized, e.g. with Title and its BacklinkCache
-        * Because attempts to serialize mConn end in "can't serialize PDO objects" exceptions, we simply disallow
-        * to serialize anything in this class.
-        */
-       function __sleep() {
-               return array();
-       }
-
        function getType() {
                return 'sqlite';
        }
@@ -88,14 +77,9 @@ class DatabaseSqlite extends DatabaseBase {
                } catch ( PDOException $e ) {
                        $err = $e->getMessage();
                }
-               if ( $this->mConn === false ) {
+               if ( !$this->mConn ) {
                        wfDebug( "DB connection error: $err\n" );
-                       if ( !$this->mFailFunction ) {
-                               throw new DBConnectionError( $this, $err );
-                       } else {
-                               return false;
-                       }
-
+                       throw new DBConnectionError( $this, $err );
                }
                $this->mOpened = !!$this->mConn;
                # set error codes only, don't raise exceptions
@@ -399,7 +383,7 @@ class DatabaseSqlite extends DatabaseBase {
                # SQLite can't handle multi-row inserts, so divide up into multiple single-row inserts
                if ( isset( $a[0] ) && is_array( $a[0] ) ) {
                        $ret = true;
-                       foreach ( $a as $k => $v ) {
+                       foreach ( $a as $v ) {
                                if ( !parent::insert( $table, $v, "$fname/multi-row", $options ) ) {
                                        $ret = false;
                                }
@@ -417,7 +401,7 @@ class DatabaseSqlite extends DatabaseBase {
                # SQLite can't handle multi-row replaces, so divide up into multiple single-row queries
                if ( isset( $rows[0] ) && is_array( $rows[0] ) ) {
                        $ret = true;
-                       foreach ( $rows as $k => $v ) {
+                       foreach ( $rows as $v ) {
                                if ( !parent::replace( $table, $uniqueIndexes, $v, "$fname/multi-row" ) ) {
                                        $ret = false;
                                }
@@ -554,8 +538,8 @@ class DatabaseSqlite extends DatabaseBase {
        }
 
        /**
-        * Called by the installer script (when modified according to the MediaWikiLite installation instructions)
-        * - this is the same way PostgreSQL works, MySQL reads in tables.sql and interwiki.sql using dbsource (which calls db->sourceFile)
+        * Called by the installer script
+        * - this is the same way PostgreSQL works, MySQL reads in tables.sql and interwiki.sql using DatabaseBase::sourceFile()
         */
        public function setup_database() {
                global $IP;
@@ -606,7 +590,9 @@ class DatabaseSqlite extends DatabaseBase {
                        // no such thing as unsigned
                        $s = preg_replace( '/\b(un)?signed\b/i', '', $s );
                        // INT -> INTEGER
-                       $s = preg_replace( '/\b(tiny|small|medium|big|)int(\s*\([\s\d]*\)|\b)/i', 'INTEGER', $s );
+                       $s = preg_replace( '/\b(tiny|small|medium|big|)int(\s*\(\s*\d+\s*\)|\b)/i', 'INTEGER', $s );
+                       // floating point types -> REAL
+                       $s = preg_replace( '/\b(float|double(\s+precision)?)(\s*\(\s*\d+\s*(,\s*\d+\s*)?\)|\b)/i', 'REAL', $s );
                        // varchar -> TEXT
                        $s = preg_replace( '/\b(var)?char\s*\(.*?\)/i', 'TEXT', $s );
                        // TEXT normalization