Mainframe98 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/359961 )

Change subject: Fix the tableExists method of MysqlBase
......................................................................

Fix the tableExists method of MysqlBase

The table name generated by Database::tableName() does not work in
MysqlBase's tableExist method, as the syntax of SHOW TABLES does not
function like other foreign db queries. It instead should use FROM
$db rather than the database name in front of the table name.
I consider this a hack, as it just splits the output of tableName(),
but this way, the escaping of that method can be recycled.

Bug: T168207
Change-Id: I7806090eaa647959fd34de8bc606eeb952161529
---
M includes/libs/rdbms/database/DatabaseMysqlBase.php
1 file changed, 10 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/61/359961/1

diff --git a/includes/libs/rdbms/database/DatabaseMysqlBase.php 
b/includes/libs/rdbms/database/DatabaseMysqlBase.php
index 50ead83..b0107a7 100644
--- a/includes/libs/rdbms/database/DatabaseMysqlBase.php
+++ b/includes/libs/rdbms/database/DatabaseMysqlBase.php
@@ -536,7 +536,16 @@
                // other than the backslash, which is the only one supported by 
SHOW TABLES
                $encLike = $this->escapeLikeInternal( $table, '\\' );
 
-               return $this->query( "SHOW TABLES LIKE '$encLike'", $fname 
)->numRows() > 0;
+               // Database::tableName returns shared tables prefixed with 
their database, which do not
+               // work in SHOW TABLES statements, so split them up.
+               if ( strpos( $encLike, '.' ) === false ) {
+                       $db = $this->mDBname;
+                       $table = $encLike;
+               } else {
+                       list( $db, $table ) = explode( '.', $encLike, 2 );
+               }
+
+               return $this->query( "SHOW TABLES FROM $db LIKE '$table'", 
$fname )->numRows() > 0;
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/359961
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7806090eaa647959fd34de8bc606eeb952161529
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Mainframe98 <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to