Commit ce88146d authored by webchick's avatar webchick

Issue #2582577 by Shlyapkin Grigoriy, Liam Morland, stefan.r, mradcliffe,...

Issue #2582577 by Shlyapkin Grigoriy, Liam Morland, stefan.r, mradcliffe, oriol_e9g, shazbot28: D8 install should check MySQL version (Syntax error or access violation: 1115 Unknown character set: 'utf8mb4')
parent 8eb65f58
......@@ -33,6 +33,16 @@ class Connection extends DatabaseConnection {
*/
const UNSUPPORTED_CHARSET = 2019;
/**
* Driver-specific error code for "Unknown character set" error.
*/
const UNKNOWN_CHARSET = 1115;
/**
* SQLSTATE error code for "Syntax error or access rule violation".
*/
const SQLSTATE_SYNTAX_ERROR = 42000;
/**
* Flag to indicate if the cleanup function in __destruct() should run.
*
......
......@@ -71,7 +71,7 @@ protected function connect() {
}
catch (\Exception $e) {
// Detect utf8mb4 incompability.
if ($e->getCode() == Connection::UNSUPPORTED_CHARSET) {
if ($e->getCode() == Connection::UNSUPPORTED_CHARSET || ($e->getCode() == Connection::SQLSTATE_SYNTAX_ERROR && $e->errorInfo[1] == Connection::UNKNOWN_CHARSET)) {
$this->fail(t('Your MySQL server and PHP MySQL driver must support utf8mb4 character encoding. Make sure to use a database system that supports this (such as MySQL/MariaDB/Percona 5.5.3 and up), and that the utf8mb4 character set is compiled in. See the <a href=":documentation" target="_blank">MySQL documentation</a> for more information.', array(':documentation' => 'https://dev.mysql.com/doc/refman/5.0/en/cannot-initialize-character-set.html')));
$info = Database::getConnectionInfo();
$info_copy = $info;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment