From: Matthias Schmidt Date: Mon, 19 Aug 2019 15:59:25 +0000 (+0200) Subject: Try to create non-existing database during setup (#3010) X-Git-Tag: 5.2.0_Beta_1~16^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a028f8e6af6065417ee0600714457c08193864ec;p=GitHub%2FWoltLab%2FWCF.git Try to create non-existing database during setup (#3010) Close #2979 --- diff --git a/wcfsetup/install/files/lib/system/WCFSetup.class.php b/wcfsetup/install/files/lib/system/WCFSetup.class.php index 1dabcf811d..f7fde95bef 100644 --- a/wcfsetup/install/files/lib/system/WCFSetup.class.php +++ b/wcfsetup/install/files/lib/system/WCFSetup.class.php @@ -682,12 +682,26 @@ class WCFSetup extends WCF { $db = new MySQLDatabase($dbHostWithoutPort, $dbUser, $dbPassword, $dbName, $dbPort, true, !!(self::$developerMode)); } catch (DatabaseException $e) { - // work-around for older MySQL versions that don't know utf8mb4 - if ($e->getPrevious()->getCode() == 1115) { - throw new SystemException("Insufficient MySQL version. Version '5.5.35' or greater is needed."); + switch ($e->getPrevious()->getCode()) { + // try to manually create non-existing database + case 1049: + try { + $db = new MySQLDatabase($dbHostWithoutPort, $dbUser, $dbPassword, $dbName, $dbPort, true, true); + } + catch (DatabaseException $e) { + throw new SystemException("Unknown database '{$dbName}'. Please create the database manually."); + } + + break; + + // work-around for older MySQL versions that don't know utf8mb4 + case 1115: + throw new SystemException("Insufficient MySQL version. Version '5.5.35' or greater is needed."); + break; + + default: + throw $e; } - - throw $e; } // check sql version