Merge "Use ParserOutput stateless transforms"
[lhc/web/wiklou.git] / includes / libs / rdbms / database / DatabaseSqlite.php
index 2a5deb6..2b06607 100644 (file)
  * @file
  * @ingroup Database
  */
-use Wikimedia\Rdbms\Blob;
-use Wikimedia\Rdbms\SQLiteField;
-use Wikimedia\Rdbms\ResultWrapper;
+namespace Wikimedia\Rdbms;
+
+use PDO;
+use PDOException;
+use LockManager;
+use FSLockManager;
+use InvalidArgumentException;
+use RuntimeException;
+use stdClass;
 
 /**
  * @ingroup Database
@@ -116,8 +122,10 @@ class DatabaseSqlite extends Database {
                $p['dbFilePath'] = $filename;
                $p['schema'] = false;
                $p['tablePrefix'] = '';
+               /** @var DatabaseSqlite $db */
+               $db = Database::factory( 'sqlite', $p );
 
-               return Database::factory( 'sqlite', $p );
+               return $db;
        }
 
        /**
@@ -430,16 +438,6 @@ class DatabaseSqlite extends Database {
                return str_replace( '"', '', parent::tableName( $name, $format ) );
        }
 
-       /**
-        * Index names have DB scope
-        *
-        * @param string $index
-        * @return string
-        */
-       protected function indexName( $index ) {
-               return $index;
-       }
-
        /**
         * This must be called after nextSequenceVal
         *
@@ -569,7 +567,7 @@ class DatabaseSqlite extends Database {
 
        /**
         * @param array $options
-        * @return string
+        * @return array
         */
        protected function makeUpdateOptionsArray( $options ) {
                $options = parent::makeUpdateOptionsArray( $options );
@@ -792,7 +790,7 @@ class DatabaseSqlite extends Database {
                        return "x'" . bin2hex( $s->fetch() ) . "'";
                } elseif ( is_bool( $s ) ) {
                        return (int)$s;
-               } elseif ( strpos( $s, "\0" ) !== false ) {
+               } elseif ( strpos( (string)$s, "\0" ) !== false ) {
                        // SQLite doesn't support \0 in strings, so use the hex representation as a workaround.
                        // This is a known limitation of SQLite's mprintf function which PDO
                        // should work around, but doesn't. I have reported this to php.net as bug #63419:
@@ -808,24 +806,12 @@ class DatabaseSqlite extends Database {
                                'For consistency all binary data should have been ' .
                                'first processed with self::encodeBlob()'
                        );
-                       return "x'" . bin2hex( $s ) . "'";
+                       return "x'" . bin2hex( (string)$s ) . "'";
                } else {
-                       return $this->mConn->quote( $s );
+                       return $this->mConn->quote( (string)$s );
                }
        }
 
-       /**
-        * @return string
-        */
-       function buildLike() {
-               $params = func_get_args();
-               if ( count( $params ) > 0 && is_array( $params[0] ) ) {
-                       $params = $params[0];
-               }
-
-               return parent::buildLike( $params ) . "ESCAPE '\' ";
-       }
-
        /**
         * @param string $field Field or column to cast
         * @return string
@@ -1058,3 +1044,5 @@ class DatabaseSqlite extends Database {
                return 'SQLite ' . (string)$this->mConn->getAttribute( PDO::ATTR_SERVER_VERSION );
        }
 }
+
+class_alias( DatabaseSqlite::class, 'DatabaseSqlite' );