Followup to r77713, rename quote_ident to addIdentifierQuotes to follow naming conven...
authorDaniel Friesen <dantman@users.mediawiki.org>
Sat, 4 Dec 2010 15:14:08 +0000 (15:14 +0000)
committerDaniel Friesen <dantman@users.mediawiki.org>
Sat, 4 Dec 2010 15:14:08 +0000 (15:14 +0000)
includes/db/Database.php
includes/db/DatabaseIbm_db2.php
includes/db/DatabaseMssql.php
includes/db/DatabaseOracle.php
includes/db/DatabasePostgres.php
includes/db/DatabaseSqlite.php
includes/installer/PostgresInstaller.php

index e74d06e..7248bb9 100644 (file)
@@ -1699,10 +1699,21 @@ abstract class DatabaseBase implements DatabaseType {
         * names, other databases which use something other than backticks can replace
         * this with something else
         */      
-       function quote_ident( $s ) {
+       public function addIdentifierQuotes( $s ) {
                return "`" . $this->strencode( $s ) . "`";
        }
 
+       /**
+        * Backwards compatibility, identifier quoting originated in DatabasePostgres
+        * which used quote_ident which does not follow our naming conventions
+        * was renamed to addIdentifierQuotes.
+        * @deprecated use addIdentifierQuotes
+        */
+       function quote_ident( $s ) {
+               wfDeprecated( __METHOD__ );
+               return $this->addIdentifierQuotes( $s );
+       }
+
        /**
         * Escape string for safe LIKE usage.
         * WARNING: you should almost never use this function directly,
@@ -2516,7 +2527,7 @@ abstract class DatabaseBase implements DatabaseType {
         * 
         * '{$var}' should be used for text and is passed through the database's addQuotes method
         * `{$var}` should be used for identifiers (eg: table and database names), it is passed through
-        *          the database's quote_ident method which can be overridden if the database
+        *          the database's addIdentifierQuotes method which can be overridden if the database
         *          uses something other than backticks.
         * / *$var* / is just encoded, besides traditional dbprefix and tableoptions it's use should be avoided
         * 
@@ -2528,7 +2539,7 @@ abstract class DatabaseBase implements DatabaseType {
                foreach ( $varnames as $var ) {
                        if ( isset( $GLOBALS[$var] ) ) {
                                $ins = str_replace( '\'{$' . $var . '}\'', $this->addQuotes( $GLOBALS[$var] ), $ins ); // replace '{$var}'
-                               $ins = str_replace( '`{$' . $var . '}`', $this->quote_ident( $GLOBALS[$var] ), $ins ); // replace `{$var}`
+                               $ins = str_replace( '`{$' . $var . '}`', $this->addIdentifierQuotes( $GLOBALS[$var] ), $ins ); // replace `{$var}`
                                $ins = str_replace( '/*$' . $var . '*/', $this->strencode( $GLOBALS[$var] ) , $ins ); // replace /*$var*/
                        }
                }
index a3a6829..f49ff8e 100644 (file)
@@ -647,6 +647,10 @@ EOF;
                }
        }
 
+       public function addIdentifierQuotes( $s ) {
+               return '"' . str_replace( '"', '""', $s ) . '"';
+       }
+
        /**
         * Verifies that a DB2 column/field type is numeric
         *
index 1be97c0..b51f782 100644 (file)
@@ -460,14 +460,14 @@ class DatabaseMssql extends DatabaseBase {
                                        $sql .= ',';
                                }
                                if ( is_string( $value ) ) {
-                                       $sql .= $this->quote_ident( $value );
+                                       $sql .= $this->addIdentifierQuotes( $value );
                                } elseif ( is_null( $value ) ) {
                                        $sql .= 'null';
                                } elseif ( is_array( $value ) || is_object( $value ) ) {
                                        if ( is_object( $value ) && strtolower( get_class( $value ) ) == 'blob' ) {
-                                               $sql .= $this->quote_ident( $value->fetch() );
+                                               $sql .= $this->addIdentifierQuotes( $value->fetch() );
                                        }  else {
-                                               $sql .= $this->quote_ident( serialize( $value ) );
+                                               $sql .= $this->addIdentifierQuotes( serialize( $value ) );
                                        }
                                } else {
                                        $sql .= $value;
@@ -997,7 +997,7 @@ class DatabaseMssql extends DatabaseBase {
                }
        }
 
-       function quote_ident( $s ) {
+       function addIdentifierQuotes( $s ) {
                return "'" . str_replace( "'", "''", $s ) . "'";
        }
 
index 876188d..b5d67dd 100644 (file)
@@ -1125,7 +1125,7 @@ class DatabaseOracle extends DatabaseBase {
                return "'" . $this->strencode( $s ) . "'";
        }
 
-       function quote_ident( $s ) {
+       function addIdentifierQuotes( $s ) {
                return '"' . str_replace( '"', '""', $s ) . '"';
        }
 
index ea768e2..55385f0 100644 (file)
@@ -209,7 +209,7 @@ class DatabasePostgres extends DatabaseBase {
                        && preg_match( '/^\w+$/', $wgDBmwschema )
                        && preg_match( '/^\w+$/', $wgDBts2schema )
                ) {
-                       $safeschema = $this->quote_ident( $wgDBmwschema );
+                       $safeschema = $this->addIdentifierQuotes( $wgDBmwschema );
                        $this->doQuery( "SET search_path = $safeschema, $wgDBts2schema, public" );
                }
 
@@ -238,7 +238,7 @@ class DatabasePostgres extends DatabaseBase {
                }
                print 'version ' . htmlspecialchars( $this->numeric_version ) . " is OK.</li>\n";
 
-               $safeuser = $this->quote_ident( $wgDBuser );
+               $safeuser = $this->addIdentifierQuotes( $wgDBuser );
                // Are we connecting as a superuser for the first time?
                if ( $superuser ) {
                        // Are we really a superuser? Check out our rights
@@ -284,7 +284,7 @@ class DatabasePostgres extends DatabaseBase {
                                                dieout( );
                                        }
                                        print '<li>Creating database <b>' . htmlspecialchars( $wgDBname ) . '</b>...';
-                                       $safename = $this->quote_ident( $wgDBname );
+                                       $safename = $this->addIdentifierQuotes( $wgDBname );
                                        $SQL = "CREATE DATABASE $safename OWNER $safeuser ";
                                        $this->doQuery( $SQL );
                                        print "OK</li>\n";
@@ -337,7 +337,7 @@ class DatabasePostgres extends DatabaseBase {
 
                        // Setup the schema for this user if needed
                        $result = $this->schemaExists( $wgDBmwschema );
-                       $safeschema = $this->quote_ident( $wgDBmwschema );
+                       $safeschema = $this->addIdentifierQuotes( $wgDBmwschema );
                        if ( !$result ) {
                                print '<li>Creating schema <b>' . htmlspecialchars( $wgDBmwschema ) . '</b> ...';
                                $result = $this->doQuery( "CREATE SCHEMA $safeschema AUTHORIZATION $safeuser" );
@@ -398,7 +398,7 @@ class DatabasePostgres extends DatabaseBase {
                                // Let's check all four, just to be safe
                                error_reporting( 0 );
                                $ts2tables = array( 'cfg', 'cfgmap', 'dict', 'parser' );
-                               $safetsschema = $this->quote_ident( $wgDBts2schema );
+                               $safetsschema = $this->addIdentifierQuotes( $wgDBts2schema );
                                foreach ( $ts2tables as $tname ) {
                                        $SQL = "SELECT count(*) FROM $safetsschema.pg_ts_$tname";
                                        $res = $this->doQuery( $SQL );
@@ -466,7 +466,7 @@ class DatabasePostgres extends DatabaseBase {
                        if ( !$result ) {
                                print '<li>Creating schema <b>' . htmlspecialchars( $wgDBmwschema ) . '</b> ...';
                                error_reporting( 0 );
-                               $safeschema = $this->quote_ident( $wgDBmwschema );
+                               $safeschema = $this->addIdentifierQuotes( $wgDBmwschema );
                                $result = $this->doQuery( "CREATE SCHEMA $safeschema" );
                                error_reporting( E_ALL );
                                if ( !$result ) {
@@ -521,9 +521,9 @@ class DatabasePostgres extends DatabaseBase {
 
                        // Fix up the search paths if needed
                        print '<li>Setting the search path for user "' . htmlspecialchars( $wgDBuser ) . '" ...';
-                       $path = $this->quote_ident( $wgDBmwschema );
+                       $path = $this->addIdentifierQuotes( $wgDBmwschema );
                        if ( $wgDBts2schema !== $wgDBmwschema ) {
-                               $path .= ', '. $this->quote_ident( $wgDBts2schema );
+                               $path .= ', '. $this->addIdentifierQuotes( $wgDBts2schema );
                        }
                        if ( $wgDBmwschema !== 'public' && $wgDBts2schema !== 'public' ) {
                                $path .= ', public';
@@ -1300,7 +1300,7 @@ SQL;
                return "'" . pg_escape_string( $this->mConn, $s ) . "'";
        }
 
-       function quote_ident( $s ) {
+       function addIdentifierQuotes( $s ) {
                return '"' . str_replace( '"', '""', $s ) . '"';
        }
 
index 5bc36ce..6fb59f7 100644 (file)
@@ -530,7 +530,7 @@ class DatabaseSqlite extends DatabaseBase {
                }
        }
 
-       function quote_ident( $s ) {
+       function addIdentifierQuotes( $s ) {
                return '"' . str_replace( '"', '""', $s ) . '"';
        }
 
index 5851bb1..9d832f9 100644 (file)
@@ -127,7 +127,7 @@ class PostgresInstaller extends DatabaseInstaller {
                // If not, Postgres will happily and silently go to the next search_path item
                $schema = $this->getVar( 'wgDBmwschema' );
                $ctest = 'mediawiki_test_table';
-               $safeschema = $conn->quote_ident( $schema );
+               $safeschema = $conn->addIdentifierQuotes( $schema );
                if ( $conn->tableExists( $ctest, $schema ) ) {
                        $conn->doQuery( "DROP TABLE $safeschema.$ctest" );
                }