Index: trunk/phase3/includes/db/DatabaseOracle.php |
— | — | @@ -1125,7 +1125,7 @@ |
1126 | 1126 | return "'" . $this->strencode( $s ) . "'"; |
1127 | 1127 | } |
1128 | 1128 | |
1129 | | - function quote_ident( $s ) { |
| 1129 | + function addIdentifierQuotes( $s ) { |
1130 | 1130 | return '"' . str_replace( '"', '""', $s ) . '"'; |
1131 | 1131 | } |
1132 | 1132 | |
Index: trunk/phase3/includes/db/DatabasePostgres.php |
— | — | @@ -209,7 +209,7 @@ |
210 | 210 | && preg_match( '/^\w+$/', $wgDBmwschema ) |
211 | 211 | && preg_match( '/^\w+$/', $wgDBts2schema ) |
212 | 212 | ) { |
213 | | - $safeschema = $this->quote_ident( $wgDBmwschema ); |
| 213 | + $safeschema = $this->addIdentifierQuotes( $wgDBmwschema ); |
214 | 214 | $this->doQuery( "SET search_path = $safeschema, $wgDBts2schema, public" ); |
215 | 215 | } |
216 | 216 | |
— | — | @@ -238,7 +238,7 @@ |
239 | 239 | } |
240 | 240 | print 'version ' . htmlspecialchars( $this->numeric_version ) . " is OK.</li>\n"; |
241 | 241 | |
242 | | - $safeuser = $this->quote_ident( $wgDBuser ); |
| 242 | + $safeuser = $this->addIdentifierQuotes( $wgDBuser ); |
243 | 243 | // Are we connecting as a superuser for the first time? |
244 | 244 | if ( $superuser ) { |
245 | 245 | // Are we really a superuser? Check out our rights |
— | — | @@ -284,7 +284,7 @@ |
285 | 285 | dieout( ); |
286 | 286 | } |
287 | 287 | print '<li>Creating database <b>' . htmlspecialchars( $wgDBname ) . '</b>...'; |
288 | | - $safename = $this->quote_ident( $wgDBname ); |
| 288 | + $safename = $this->addIdentifierQuotes( $wgDBname ); |
289 | 289 | $SQL = "CREATE DATABASE $safename OWNER $safeuser "; |
290 | 290 | $this->doQuery( $SQL ); |
291 | 291 | print "OK</li>\n"; |
— | — | @@ -337,7 +337,7 @@ |
338 | 338 | |
339 | 339 | // Setup the schema for this user if needed |
340 | 340 | $result = $this->schemaExists( $wgDBmwschema ); |
341 | | - $safeschema = $this->quote_ident( $wgDBmwschema ); |
| 341 | + $safeschema = $this->addIdentifierQuotes( $wgDBmwschema ); |
342 | 342 | if ( !$result ) { |
343 | 343 | print '<li>Creating schema <b>' . htmlspecialchars( $wgDBmwschema ) . '</b> ...'; |
344 | 344 | $result = $this->doQuery( "CREATE SCHEMA $safeschema AUTHORIZATION $safeuser" ); |
— | — | @@ -398,7 +398,7 @@ |
399 | 399 | // Let's check all four, just to be safe |
400 | 400 | error_reporting( 0 ); |
401 | 401 | $ts2tables = array( 'cfg', 'cfgmap', 'dict', 'parser' ); |
402 | | - $safetsschema = $this->quote_ident( $wgDBts2schema ); |
| 402 | + $safetsschema = $this->addIdentifierQuotes( $wgDBts2schema ); |
403 | 403 | foreach ( $ts2tables as $tname ) { |
404 | 404 | $SQL = "SELECT count(*) FROM $safetsschema.pg_ts_$tname"; |
405 | 405 | $res = $this->doQuery( $SQL ); |
— | — | @@ -466,7 +466,7 @@ |
467 | 467 | if ( !$result ) { |
468 | 468 | print '<li>Creating schema <b>' . htmlspecialchars( $wgDBmwschema ) . '</b> ...'; |
469 | 469 | error_reporting( 0 ); |
470 | | - $safeschema = $this->quote_ident( $wgDBmwschema ); |
| 470 | + $safeschema = $this->addIdentifierQuotes( $wgDBmwschema ); |
471 | 471 | $result = $this->doQuery( "CREATE SCHEMA $safeschema" ); |
472 | 472 | error_reporting( E_ALL ); |
473 | 473 | if ( !$result ) { |
— | — | @@ -521,9 +521,9 @@ |
522 | 522 | |
523 | 523 | // Fix up the search paths if needed |
524 | 524 | print '<li>Setting the search path for user "' . htmlspecialchars( $wgDBuser ) . '" ...'; |
525 | | - $path = $this->quote_ident( $wgDBmwschema ); |
| 525 | + $path = $this->addIdentifierQuotes( $wgDBmwschema ); |
526 | 526 | if ( $wgDBts2schema !== $wgDBmwschema ) { |
527 | | - $path .= ', '. $this->quote_ident( $wgDBts2schema ); |
| 527 | + $path .= ', '. $this->addIdentifierQuotes( $wgDBts2schema ); |
528 | 528 | } |
529 | 529 | if ( $wgDBmwschema !== 'public' && $wgDBts2schema !== 'public' ) { |
530 | 530 | $path .= ', public'; |
— | — | @@ -1300,7 +1300,7 @@ |
1301 | 1301 | return "'" . pg_escape_string( $this->mConn, $s ) . "'"; |
1302 | 1302 | } |
1303 | 1303 | |
1304 | | - function quote_ident( $s ) { |
| 1304 | + function addIdentifierQuotes( $s ) { |
1305 | 1305 | return '"' . str_replace( '"', '""', $s ) . '"'; |
1306 | 1306 | } |
1307 | 1307 | |
Index: trunk/phase3/includes/db/DatabaseIbm_db2.php |
— | — | @@ -647,6 +647,10 @@ |
648 | 648 | } |
649 | 649 | } |
650 | 650 | |
| 651 | + public function addIdentifierQuotes( $s ) { |
| 652 | + return '"' . str_replace( '"', '""', $s ) . '"'; |
| 653 | + } |
| 654 | + |
651 | 655 | /** |
652 | 656 | * Verifies that a DB2 column/field type is numeric |
653 | 657 | * |
Index: trunk/phase3/includes/db/Database.php |
— | — | @@ -1699,11 +1699,22 @@ |
1700 | 1700 | * names, other databases which use something other than backticks can replace |
1701 | 1701 | * this with something else |
1702 | 1702 | */ |
1703 | | - function quote_ident( $s ) { |
| 1703 | + public function addIdentifierQuotes( $s ) { |
1704 | 1704 | return "`" . $this->strencode( $s ) . "`"; |
1705 | 1705 | } |
1706 | 1706 | |
1707 | 1707 | /** |
| 1708 | + * Backwards compatibility, identifier quoting originated in DatabasePostgres |
| 1709 | + * which used quote_ident which does not follow our naming conventions |
| 1710 | + * was renamed to addIdentifierQuotes. |
| 1711 | + * @deprecated use addIdentifierQuotes |
| 1712 | + */ |
| 1713 | + function quote_ident( $s ) { |
| 1714 | + wfDeprecated( __METHOD__ ); |
| 1715 | + return $this->addIdentifierQuotes( $s ); |
| 1716 | + } |
| 1717 | + |
| 1718 | + /** |
1708 | 1719 | * Escape string for safe LIKE usage. |
1709 | 1720 | * WARNING: you should almost never use this function directly, |
1710 | 1721 | * instead use buildLike() that escapes everything automatically |
— | — | @@ -2516,7 +2527,7 @@ |
2517 | 2528 | * |
2518 | 2529 | * '{$var}' should be used for text and is passed through the database's addQuotes method |
2519 | 2530 | * `{$var}` should be used for identifiers (eg: table and database names), it is passed through |
2520 | | - * the database's quote_ident method which can be overridden if the database |
| 2531 | + * the database's addIdentifierQuotes method which can be overridden if the database |
2521 | 2532 | * uses something other than backticks. |
2522 | 2533 | * / *$var* / is just encoded, besides traditional dbprefix and tableoptions it's use should be avoided |
2523 | 2534 | * |
— | — | @@ -2528,7 +2539,7 @@ |
2529 | 2540 | foreach ( $varnames as $var ) { |
2530 | 2541 | if ( isset( $GLOBALS[$var] ) ) { |
2531 | 2542 | $ins = str_replace( '\'{$' . $var . '}\'', $this->addQuotes( $GLOBALS[$var] ), $ins ); // replace '{$var}' |
2532 | | - $ins = str_replace( '`{$' . $var . '}`', $this->quote_ident( $GLOBALS[$var] ), $ins ); // replace `{$var}` |
| 2543 | + $ins = str_replace( '`{$' . $var . '}`', $this->addIdentifierQuotes( $GLOBALS[$var] ), $ins ); // replace `{$var}` |
2533 | 2544 | $ins = str_replace( '/*$' . $var . '*/', $this->strencode( $GLOBALS[$var] ) , $ins ); // replace /*$var*/ |
2534 | 2545 | } |
2535 | 2546 | } |
Index: trunk/phase3/includes/db/DatabaseMssql.php |
— | — | @@ -460,14 +460,14 @@ |
461 | 461 | $sql .= ','; |
462 | 462 | } |
463 | 463 | if ( is_string( $value ) ) { |
464 | | - $sql .= $this->quote_ident( $value ); |
| 464 | + $sql .= $this->addIdentifierQuotes( $value ); |
465 | 465 | } elseif ( is_null( $value ) ) { |
466 | 466 | $sql .= 'null'; |
467 | 467 | } elseif ( is_array( $value ) || is_object( $value ) ) { |
468 | 468 | if ( is_object( $value ) && strtolower( get_class( $value ) ) == 'blob' ) { |
469 | | - $sql .= $this->quote_ident( $value->fetch() ); |
| 469 | + $sql .= $this->addIdentifierQuotes( $value->fetch() ); |
470 | 470 | } else { |
471 | | - $sql .= $this->quote_ident( serialize( $value ) ); |
| 471 | + $sql .= $this->addIdentifierQuotes( serialize( $value ) ); |
472 | 472 | } |
473 | 473 | } else { |
474 | 474 | $sql .= $value; |
— | — | @@ -997,7 +997,7 @@ |
998 | 998 | } |
999 | 999 | } |
1000 | 1000 | |
1001 | | - function quote_ident( $s ) { |
| 1001 | + function addIdentifierQuotes( $s ) { |
1002 | 1002 | return "'" . str_replace( "'", "''", $s ) . "'"; |
1003 | 1003 | } |
1004 | 1004 | |
Index: trunk/phase3/includes/db/DatabaseSqlite.php |
— | — | @@ -530,7 +530,7 @@ |
531 | 531 | } |
532 | 532 | } |
533 | 533 | |
534 | | - function quote_ident( $s ) { |
| 534 | + function addIdentifierQuotes( $s ) { |
535 | 535 | return '"' . str_replace( '"', '""', $s ) . '"'; |
536 | 536 | } |
537 | 537 | |
Index: trunk/phase3/includes/installer/PostgresInstaller.php |
— | — | @@ -127,7 +127,7 @@ |
128 | 128 | // If not, Postgres will happily and silently go to the next search_path item |
129 | 129 | $schema = $this->getVar( 'wgDBmwschema' ); |
130 | 130 | $ctest = 'mediawiki_test_table'; |
131 | | - $safeschema = $conn->quote_ident( $schema ); |
| 131 | + $safeschema = $conn->addIdentifierQuotes( $schema ); |
132 | 132 | if ( $conn->tableExists( $ctest, $schema ) ) { |
133 | 133 | $conn->doQuery( "DROP TABLE $safeschema.$ctest" ); |
134 | 134 | } |