From 5d56bcb925af653fed427e90a1cfb982de386720 Mon Sep 17 00:00:00 2001 From: Paladox Date: Fri, 19 May 2017 20:43:26 +0000 Subject: [PATCH] Fix the web updater It kept failing with Error: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ESCAPE '`'' at line 1 (localhost) Bug: T165805 Change-Id: I2671415fc34b1e6226104c88ca21fafc860bb7fb --- includes/installer/MysqlInstaller.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/includes/installer/MysqlInstaller.php b/includes/installer/MysqlInstaller.php index 09051f410d..4f0b66c1d4 100644 --- a/includes/installer/MysqlInstaller.php +++ b/includes/installer/MysqlInstaller.php @@ -179,8 +179,8 @@ class MysqlInstaller extends DatabaseInstaller { # Determine existing default character set if ( $conn->tableExists( "revision", __METHOD__ ) ) { - $revision = $conn->buildLike( $this->getVar( 'wgDBprefix' ) . 'revision' ); - $res = $conn->query( "SHOW TABLE STATUS $revision", __METHOD__ ); + $revision = $this->escapeLikeInternal( $this->getVar( 'wgDBprefix' ) . 'revision', '\\' ); + $res = $conn->query( "SHOW TABLE STATUS LIKE '$revision'", __METHOD__ ); $row = $conn->fetchObject( $res ); if ( !$row ) { $this->parent->showMessage( 'config-show-table-status' ); @@ -221,6 +221,16 @@ class MysqlInstaller extends DatabaseInstaller { $wgDBpassword = $this->getVar( '_InstallPassword' ); } + /** + * @param string $s + * @return string + */ + protected function escapeLikeInternal( $s, $escapeChar = '`' ) { + return str_replace( [ $escapeChar, '%', '_' ], + [ "{$escapeChar}{$escapeChar}", "{$escapeChar}%", "{$escapeChar}_" ], + $s ); + } + /** * Get a list of storage engines that are available and supported * -- 2.20.1