Add parameter to tableName() to get the bare table name.
authorPlatonides <platonides@users.mediawiki.org>
Tue, 12 Apr 2011 17:00:08 +0000 (17:00 +0000)
committerPlatonides <platonides@users.mediawiki.org>
Tue, 12 Apr 2011 17:00:08 +0000 (17:00 +0000)
includes/db/Database.php

index 19a125c..7bb13df 100644 (file)
@@ -1513,9 +1513,11 @@ abstract class DatabaseBase implements DatabaseType {
         * when calling query() directly.
         *
         * @param $name String: database table name
+        * @param $quoted Boolean: Automatically pass the table name through 
+        *          addIdentifierQuotes() so that it can be used in a query.
         * @return String: full database name
         */
-       function tableName( $name ) {
+       function tableName( $name, $quoted = true ) {
                global $wgSharedDB, $wgSharedPrefix, $wgSharedTables;
                # Skip the entire process when we have a string quoted on both ends.
                # Note that we check the end so that we will still quote any use of
@@ -1561,10 +1563,10 @@ abstract class DatabaseBase implements DatabaseType {
 
                # Quote the $database and $table and apply the prefix if not quoted.
                if ( isset( $database ) ) {
-                       $database = ( $this->isQuotedIdentifier( $database ) ? $database : $this->addIdentifierQuotes( $database ) );
+                       $database = ( !$quoted || $this->isQuotedIdentifier( $database ) ? $database : $this->addIdentifierQuotes( $database ) );
                        $prefix = '';
                }
-               $table = ( $this->isQuotedIdentifier( $table ) ? $table : $this->addIdentifierQuotes( "{$prefix}{$table}" ) );
+               $table = ( !$quoted || $this->isQuotedIdentifier( $table ) ? $table : $this->addIdentifierQuotes( "{$prefix}{$table}" ) );
 
                # Merge our database and table into our final table name.
                $tableName = ( isset( $database ) ? "{$database}.{$table}" : "{$table}" );