From 4e4b9997493ceabd48455a5a23549f854001c9de Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Tue, 20 Sep 2016 10:30:00 -0700 Subject: [PATCH] Improve tableExists() for MySQL Use SHOW TABLES to avoid log spam when the table does not exist. This should make the CLI jenkins log a bit more readable. Change-Id: I027a9d0af0e42959e9f03cebb295218068a263d3 --- includes/libs/rdbms/database/DatabaseMysqlBase.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/includes/libs/rdbms/database/DatabaseMysqlBase.php b/includes/libs/rdbms/database/DatabaseMysqlBase.php index 2d19081f88..9be3edee5d 100644 --- a/includes/libs/rdbms/database/DatabaseMysqlBase.php +++ b/includes/libs/rdbms/database/DatabaseMysqlBase.php @@ -518,6 +518,12 @@ abstract class DatabaseMysqlBase extends DatabaseBase { return (int)$rows; } + function tableExists( $table, $fname = __METHOD__ ) { + $encLike = $this->buildLike( $table ); + + return $this->query( "SHOW TABLES $encLike", $fname )->numRows() > 0; + } + /** * @param string $table * @param string $field -- 2.20.1