summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwebchick2015-10-22 19:11:52 (GMT)
committerwebchick2015-10-22 19:11:52 (GMT)
commitce88146d1436d4ba85c0d3a0f0cca897def913b3 (patch)
treebddf0ae012d23fe57d96f7c0e338a7f0b1ed8511
parent8eb65f58480d569ceee0814b12632ca39109dfbe (diff)
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')
-rw-r--r--core/lib/Drupal/Core/Database/Driver/mysql/Connection.php10
-rw-r--r--core/lib/Drupal/Core/Database/Driver/mysql/Install/Tasks.php2
2 files changed, 11 insertions, 1 deletions
diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php b/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php
index c48c275..2bfc330 100644
--- a/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php
+++ b/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php
@@ -34,6 +34,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.
*
* @var bool
diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Install/Tasks.php b/core/lib/Drupal/Core/Database/Driver/mysql/Install/Tasks.php
index 37b99aa..de6abc4 100644
--- a/core/lib/Drupal/Core/Database/Driver/mysql/Install/Tasks.php
+++ b/core/lib/Drupal/Core/Database/Driver/mysql/Install/Tasks.php
@@ -71,7 +71,7 @@ class Tasks extends InstallTasks {
}
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;