Skip to content
Snippets Groups Projects
Verified Commit 28d407eb authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3437786 by quietone, longwave, catch, Gábor Hojtsy: Remove...

Issue #3437786 by quietone, longwave, catch, Gábor Hojtsy: Remove MYSQLND_MINIMUM_VERSION and LIBMYSQLCLIENT_MINIMUM_VERSION checks
parent b59e63e9
No related branches found
No related tags found
29 merge requests!11131[10.4.x-only-DO-NOT-MERGE]: Issue ##2842525 Ajax attached to Views exposed filter form does not trigger callbacks,!9470[10.3.x-only-DO-NOT-MERGE]: #3331771 Fix file_get_contents(): Passing null to parameter,!8540Issue #3457061: Bootstrap Modal dialog Not closing after 10.3.0 Update,!8528Issue #3456871 by Tim Bozeman: Support NULL services,!8373Issue #3427374 by danflanagan8, Vighneshh: taxonomy_tid ViewsArgumentDefault...,!7526Expose roles in response,!7352Draft: Resolve #3203489 "Set filename as",!3878Removed unused condition head title for views,!3818Issue #2140179: $entity->original gets stale between updates,!3742Issue #3328429: Create item list field formatter for displaying ordered and unordered lists,!3731Claro: role=button on status report items,!3651Issue #3347736: Create new SDC component for Olivero (header-search),!3531Issue #3336994: StringFormatter always displays links to entity even if the user in context does not have access,!3355Issue #3209129: Scrolling problems when adding a block via layout builder,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!3133core/modules/system/css/components/hidden.module.css,!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!2812Issue #3312049: [Followup] Fix Drupal.Commenting.FunctionComment.MissingReturnType returns for NULL,!2794Issue #3100732: Allow specifying `meta` data on JSON:API objects,!2378Issue #2875033: Optimize joins and table selection in SQL entity query implementation,!2062Issue #3246454: Add weekly granularity to views date sort,!1105Issue #3025039: New non translatable field on translatable content throws error,!1073issue #3191727: Focus states on mobile second level navigation items fixed,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!877Issue #2708101: Default value for link text is not saved,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493
Pipeline #138703 canceled
...@@ -36,21 +36,6 @@ class Connection extends DatabaseConnection implements SupportsTemporaryTablesIn ...@@ -36,21 +36,6 @@ class Connection extends DatabaseConnection implements SupportsTemporaryTablesIn
*/ */
const CONNECTION_REFUSED = 2002; const CONNECTION_REFUSED = 2002;
/**
* Error code for "Can't initialize character set" error.
*/
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;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
...@@ -116,13 +101,6 @@ public function __construct(\PDO $connection, array $connection_options) { ...@@ -116,13 +101,6 @@ public function __construct(\PDO $connection, array $connection_options) {
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function open(array &$connection_options = []) { public static function open(array &$connection_options = []) {
if (isset($connection_options['_dsn_utf8_fallback']) && $connection_options['_dsn_utf8_fallback'] === TRUE) {
// Only used during the installer version check, as a fallback from utf8mb4.
$charset = 'utf8';
}
else {
$charset = 'utf8mb4';
}
// The DSN should use either a socket or a host/port. // The DSN should use either a socket or a host/port.
if (isset($connection_options['unix_socket'])) { if (isset($connection_options['unix_socket'])) {
$dsn = 'mysql:unix_socket=' . $connection_options['unix_socket']; $dsn = 'mysql:unix_socket=' . $connection_options['unix_socket'];
...@@ -134,7 +112,7 @@ public static function open(array &$connection_options = []) { ...@@ -134,7 +112,7 @@ public static function open(array &$connection_options = []) {
// Character set is added to dsn to ensure PDO uses the proper character // Character set is added to dsn to ensure PDO uses the proper character
// set when escaping. This has security implications. See // set when escaping. This has security implications. See
// https://www.drupal.org/node/1201452 for further discussion. // https://www.drupal.org/node/1201452 for further discussion.
$dsn .= ';charset=' . $charset; $dsn .= ';charset=utf8mb4';
if (!empty($connection_options['database'])) { if (!empty($connection_options['database'])) {
$dsn .= ';dbname=' . $connection_options['database']; $dsn .= ';dbname=' . $connection_options['database'];
} }
...@@ -202,10 +180,10 @@ public static function open(array &$connection_options = []) { ...@@ -202,10 +180,10 @@ public static function open(array &$connection_options = []) {
// 'utf8mb4_general_ci' (MySQL 5) or 'utf8mb4_0900_ai_ci' (MySQL 8) for // 'utf8mb4_general_ci' (MySQL 5) or 'utf8mb4_0900_ai_ci' (MySQL 8) for
// utf8mb4. // utf8mb4.
if (!empty($connection_options['collation'])) { if (!empty($connection_options['collation'])) {
$pdo->exec('SET NAMES ' . $charset . ' COLLATE ' . $connection_options['collation']); $pdo->exec('SET NAMES utf8mb4 COLLATE ' . $connection_options['collation']);
} }
else { else {
$pdo->exec('SET NAMES ' . $charset); $pdo->exec('SET NAMES utf8mb4');
} }
// Set MySQL init_commands if not already defined. Default Drupal's MySQL // Set MySQL init_commands if not already defined. Default Drupal's MySQL
......
...@@ -8,8 +8,6 @@ ...@@ -8,8 +8,6 @@
use Drupal\mysql\Driver\Database\mysql\Connection; use Drupal\mysql\Driver\Database\mysql\Connection;
use Drupal\Core\Database\DatabaseNotFoundException; use Drupal\Core\Database\DatabaseNotFoundException;
// cspell:ignore libmysqlclient
/** /**
* Specifies installation tasks for MySQL and equivalent databases. * Specifies installation tasks for MySQL and equivalent databases.
*/ */
...@@ -31,16 +29,6 @@ class Tasks extends InstallTasks { ...@@ -31,16 +29,6 @@ class Tasks extends InstallTasks {
*/ */
const MARIADB_MINIMUM_VERSION = '10.3.7'; const MARIADB_MINIMUM_VERSION = '10.3.7';
/**
* Minimum required MySQLnd version.
*/
const MYSQLND_MINIMUM_VERSION = '5.0.9';
/**
* Minimum required libmysqlclient version.
*/
const LIBMYSQLCLIENT_MINIMUM_VERSION = '5.5.3';
/** /**
* The PDO driver name for MySQL and equivalent databases. * The PDO driver name for MySQL and equivalent databases.
* *
...@@ -94,34 +82,7 @@ protected function connect() { ...@@ -94,34 +82,7 @@ protected function connect() {
// This doesn't actually test the connection. // This doesn't actually test the connection.
Database::setActiveConnection(); Database::setActiveConnection();
// Now actually do a check. // Now actually do a check.
try { Database::getConnection();
Database::getConnection();
}
catch (\Exception $e) {
// Detect utf8mb4 incompatibility.
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.', [':documentation' => 'https://dev.mysql.com/doc/refman/5.0/en/cannot-initialize-character-set.html']));
$info = Database::getConnectionInfo();
$info_copy = $info;
// Set a flag to fall back to utf8. Note: this flag should only be
// used here and is for internal use only.
$info_copy['default']['_dsn_utf8_fallback'] = TRUE;
// In order to change the Database::$databaseInfo array, we need to
// remove the active connection, then re-add it with the new info.
Database::removeConnection('default');
Database::addConnectionInfo('default', 'default', $info_copy['default']);
// Connect with the new database info, using the utf8 character set so
// that we can run the checkEngineVersion test.
Database::getConnection();
// Revert to the old settings.
Database::removeConnection('default');
Database::addConnectionInfo('default', 'default', $info['default']);
}
else {
// Rethrow the exception.
throw $e;
}
}
$this->pass('Drupal can CONNECT to the database ok.'); $this->pass('Drupal can CONNECT to the database ok.');
} }
catch (\Exception $e) { catch (\Exception $e) {
...@@ -203,27 +164,4 @@ public function ensureInnoDbAvailable() { ...@@ -203,27 +164,4 @@ public function ensureInnoDbAvailable() {
} }
} }
/**
* {@inheritdoc}
*/
protected function checkEngineVersion() {
parent::checkEngineVersion();
// Ensure that the MySQL driver supports utf8mb4 encoding.
$version = Database::getConnection()->clientVersion();
if (str_contains($version, 'mysqlnd')) {
// The mysqlnd driver supports utf8mb4 starting at version 5.0.9.
$version = preg_replace('/^\D+([\d.]+).*/', '$1', $version);
if (version_compare($version, self::MYSQLND_MINIMUM_VERSION, '<')) {
$this->fail(t("The MySQLnd driver version %version is less than the minimum required version. Upgrade to MySQLnd version %mysqlnd_minimum_version or up, or alternatively switch mysql drivers to libmysqlclient version %libmysqlclient_minimum_version or up.", ['%version' => $version, '%mysqlnd_minimum_version' => self::MYSQLND_MINIMUM_VERSION, '%libmysqlclient_minimum_version' => self::LIBMYSQLCLIENT_MINIMUM_VERSION]));
}
}
else {
// The libmysqlclient driver supports utf8mb4 starting at version 5.5.3.
if (version_compare($version, self::LIBMYSQLCLIENT_MINIMUM_VERSION, '<')) {
$this->fail(t("The libmysqlclient driver version %version is less than the minimum required version. Upgrade to libmysqlclient version %libmysqlclient_minimum_version or up, or alternatively switch mysql drivers to MySQLnd version %mysqlnd_minimum_version or up.", ['%version' => $version, '%libmysqlclient_minimum_version' => self::LIBMYSQLCLIENT_MINIMUM_VERSION, '%mysqlnd_minimum_version' => self::MYSQLND_MINIMUM_VERSION]));
}
}
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment