Merge "Add support for PHP7 random_bytes in favor of mcrypt_create_iv"
[lhc/web/wiklou.git] / includes / libs / rdbms / database / DatabaseSqlite.php
index 3ccf3f0..090ce8e 100644 (file)
@@ -21,6 +21,9 @@
  * @file
  * @ingroup Database
  */
+use Wikimedia\Rdbms\Blob;
+use Wikimedia\Rdbms\SQLiteField;
+use Wikimedia\Rdbms\ResultWrapper;
 
 /**
  * @ingroup Database
@@ -31,16 +34,13 @@ class DatabaseSqlite extends Database {
 
        /** @var string Directory */
        protected $dbDir;
-
        /** @var string File name for SQLite database file */
        protected $dbPath;
-
        /** @var string Transaction mode */
        protected $trxMode;
 
        /** @var int The number of rows affected as an integer */
        protected $mAffectedRows;
-
        /** @var resource */
        protected $mLastResult;
 
@@ -145,7 +145,7 @@ class DatabaseSqlite extends Database {
         * @param string $dbName
         *
         * @throws DBConnectionError
-        * @return PDO
+        * @return bool
         */
        function open( $server, $user, $pass, $dbName ) {
                $this->close();
@@ -156,7 +156,7 @@ class DatabaseSqlite extends Database {
                }
                $this->openFile( $fileName );
 
-               return $this->mConn;
+               return (bool)$this->mConn;
        }
 
        /**
@@ -199,6 +199,10 @@ class DatabaseSqlite extends Database {
                return false;
        }
 
+       public function selectDB( $db ) {
+               return false; // doesn't make sense
+       }
+
        /**
         * @return string SQLite DB file path
         * @since 1.25
@@ -267,7 +271,7 @@ class DatabaseSqlite extends Database {
        }
 
        /**
-        * Attaches external database to our connection, see http://sqlite.org/lang_attach.html
+        * Attaches external database to our connection, see https://sqlite.org/lang_attach.html
         * for details.
         *
         * @param string $name Database name to be used in queries like
@@ -494,15 +498,12 @@ class DatabaseSqlite extends Database {
         * @param string $table
         * @param string $index
         * @param string $fname
-        * @return array
+        * @return array|false
         */
        function indexInfo( $table, $index, $fname = __METHOD__ ) {
                $sql = 'PRAGMA index_info(' . $this->addQuotes( $this->indexName( $index ) ) . ')';
                $res = $this->query( $sql, $fname );
-               if ( !$res ) {
-                       return null;
-               }
-               if ( $res->numRows() == 0 ) {
+               if ( !$res || $res->numRows() == 0 ) {
                        return false;
                }
                $info = [];
@@ -667,7 +668,7 @@ class DatabaseSqlite extends Database {
        }
 
        /**
-        * @param string $sqls
+        * @param string[] $sqls
         * @param bool $all Whether to "UNION ALL" or not
         * @return string
         */