Make addIdentifierQuotes part of IDatabase
authorBrian Wolff <bawolff+wn@gmail.com>
Sun, 17 Feb 2019 11:02:34 +0000 (11:02 +0000)
committerAaron Schulz <aschulz@wikimedia.org>
Sat, 9 Mar 2019 00:25:39 +0000 (00:25 +0000)
This is so it can be used in places that typehint an IDatabase,
ultimately so that I can make phan-taint-check happy.

Bug: T216348
Change-Id: Iabf3e9a6add380322a12cdbb6a337bad690f1370

includes/libs/rdbms/database/DBConnRef.php
includes/libs/rdbms/database/Database.php
includes/libs/rdbms/database/IDatabase.php

index f693dd5..ab70fc8 100644 (file)
@@ -392,6 +392,10 @@ class DBConnRef implements IDatabase {
                return $this->__call( __FUNCTION__, func_get_args() );
        }
 
+       public function addIdentifierQuotes( $s ) {
+               return $this->__call( __FUNCTION__, func_get_args() );
+       }
+
        public function buildLike() {
                return $this->__call( __FUNCTION__, func_get_args() );
        }
index 974c7df..174182f 100644 (file)
@@ -2664,15 +2664,6 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
                }
        }
 
-       /**
-        * Quotes an identifier using `backticks` or "double quotes" depending on the database type.
-        * MySQL uses `backticks` while basically everything else uses double quotes.
-        * Since MySQL is the odd one out here the double quotes are our generic
-        * and we implement backticks in DatabaseMysqlBase.
-        *
-        * @param string $s
-        * @return string
-        */
        public function addIdentifierQuotes( $s ) {
                return '"' . str_replace( '"', '""', $s ) . '"';
        }
index 2795883..7d9eac1 100644 (file)
@@ -1155,6 +1155,17 @@ interface IDatabase {
         */
        public function addQuotes( $s );
 
+       /**
+        * Quotes an identifier, in order to make user controlled input safe
+        *
+        * Depending on the database this will either be `backticks` or "double quotes"
+        *
+        * @param string $s
+        * @return string
+        * @since 1.33
+        */
+       public function addIdentifierQuotes( $s );
+
        /**
         * LIKE statement wrapper, receives a variable-length argument list with
         * parts of pattern to match containing either string literals that will be