X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Finstaller%2FMysqlInstaller.php;h=09051f410d2fffc0e65adbeb2979a41d75a8de53;hb=d83306610dd468077e58dcb20a9049dd4301c1b3;hp=5ff47e94f0a9348da817917ce5dac8637783863a;hpb=57eaa2bf04ce1b48bd89c10defe4de5b7d31f047;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/installer/MysqlInstaller.php b/includes/installer/MysqlInstaller.php index 5ff47e94f0..09051f410d 100644 --- a/includes/installer/MysqlInstaller.php +++ b/includes/installer/MysqlInstaller.php @@ -21,6 +21,10 @@ * @ingroup Deployment */ +use Wikimedia\Rdbms\Database; +use Wikimedia\Rdbms\DBQueryError; +use Wikimedia\Rdbms\DBConnectionError; + /** * Class for setting up the MediaWiki database using MySQL. * @@ -312,7 +316,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 +329,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 */