Never prefix table names with $wgSharedDB when used in foreign DB
[lhc/web/wiklou.git] / includes / db / Database.php
index 3072bfd..8b56ab0 100644 (file)
@@ -236,6 +236,7 @@ abstract class DatabaseBase implements DatabaseType {
 
        protected $mTablePrefix;
        protected $mFlags;
+       protected $mForeign;
        protected $mTrxLevel = 0;
        protected $mErrorCount = 0;
        protected $mLBInfo = array();
@@ -660,9 +661,10 @@ abstract class DatabaseBase implements DatabaseType {
         * @param string $dbName database name
         * @param $flags
         * @param string $tablePrefix database table prefixes. By default use the prefix gave in LocalSettings.php
+        * @param bool $foreign disable some operations specific to local databases
         */
        function __construct( $server = false, $user = false, $password = false, $dbName = false,
-               $flags = 0, $tablePrefix = 'get from global'
+               $flags = 0, $tablePrefix = 'get from global', $foreign = false
        ) {
                global $wgDBprefix, $wgCommandLineMode, $wgDebugDBTransactions;
 
@@ -689,6 +691,8 @@ abstract class DatabaseBase implements DatabaseType {
                        $this->mTablePrefix = $tablePrefix;
                }
 
+               $this->mForeign = $foreign;
+
                if ( $user ) {
                        $this->open( $server, $user, $password, $dbName );
                }
@@ -738,7 +742,8 @@ abstract class DatabaseBase implements DatabaseType {
                                isset( $p['password'] ) ? $p['password'] : false,
                                isset( $p['dbname'] ) ? $p['dbname'] : false,
                                isset( $p['flags'] ) ? $p['flags'] : 0,
-                               isset( $p['tablePrefix'] ) ? $p['tablePrefix'] : 'get from global'
+                               isset( $p['tablePrefix'] ) ? $p['tablePrefix'] : 'get from global',
+                               isset( $p['foreign'] ) ? $p['foreign'] : false
                        );
                } else {
                        return null;
@@ -945,14 +950,6 @@ abstract class DatabaseBase implements DatabaseType {
                        wfDebug( "Query {$this->mDBname} ($cnt) ($master): $sqlx\n" );
                }
 
-               if ( istainted( $sql ) & TC_MYSQL ) {
-                       if ( !Profiler::instance()->isStub() ) {
-                               wfProfileOut( $queryProf );
-                               wfProfileOut( $totalProf );
-                       }
-                       throw new MWException( 'Tainted query found' );
-               }
-
                $queryId = MWDebug::query( $sql, $fname, $isMaster );
 
                # Do the query and handle errors
@@ -2076,6 +2073,7 @@ abstract class DatabaseBase implements DatabaseType {
                } else {
                        list( $table ) = $dbDetails;
                        if ( $wgSharedDB !== null # We have a shared database
+                               && $this->mForeign == false # We're not working on a foreign database
                                && !$this->isQuotedIdentifier( $table ) # Paranoia check to prevent shared tables listing '`table`'
                                && in_array( $table, $wgSharedTables ) # A shared table is selected
                        ) {