X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Finstaller%2FMysqlInstaller.php;h=72697739c887ae78f012574f1a7276ee579771f7;hp=5ff47e94f0a9348da817917ce5dac8637783863a;hb=eb1e4bf240eebec7f572b323e8fb04810a872aee;hpb=cbdac846ce908ff089d8a29b5d2829d243afa0fc diff --git a/includes/installer/MysqlInstaller.php b/includes/installer/MysqlInstaller.php index 5ff47e94f0..72697739c8 100644 --- a/includes/installer/MysqlInstaller.php +++ b/includes/installer/MysqlInstaller.php @@ -312,7 +312,7 @@ class MysqlInstaller extends DatabaseInstaller { 'IS_GRANTABLE' => 1, ], __METHOD__ ); foreach ( $res as $row ) { - $regex = $conn->likeToRegex( $row->TABLE_SCHEMA ); + $regex = $this->likeToRegex( $row->TABLE_SCHEMA ); if ( preg_match( $regex, $this->getVar( 'wgDBname' ) ) ) { unset( $grantOptions[$row->PRIVILEGE_TYPE] ); } @@ -325,6 +325,19 @@ class MysqlInstaller extends DatabaseInstaller { return true; } + /** + * Convert a wildcard (as used in LIKE) to a regex + * Slashes are escaped, slash terminators included + */ + protected function likeToRegex( $wildcard ) { + $r = preg_quote( $wildcard, '/' ); + $r = strtr( $r, [ + '%' => '.*', + '_' => '.' + ] ); + return "/$r/s"; + } + /** * @return string */