Add a note on MySQL 8 sql_mode override

Created on 30 January 2021, over 3 years ago
Updated 10 November 2023, 8 months ago

Problem/Motivation

MySQL 8 support was introduced in Drupal 7.76. MySQL version sometimes is detected incorrectly, leaving NO_AUTO_CREATE_USER which was removed in MySQL 8.0.11.

Currently, we use

    if (version_compare($this->getAttribute(PDO::ATTR_SERVER_VERSION), '8.0.11', '<')) {
      $sql_mode .= ',NO_AUTO_CREATE_USER';
    }

The problem is PDO::ATTR_SERVER_VERSION sometimes returns the wrong version. For example, Azure and other services that use proxies may return a lower version. Or a package may return something like 8.0.11-ubuntu-0.11, which leads to wrong results of version_compare.

There's a different solution in D8, which uses an additional query to get the exact DB version: https://www.drupal.org/project/drupal/issues/3089902 β†’ .

It was decided to keep the code as is in D7 and manually override sql_mode in settings.php in case version_compare() fails.
https://www.drupal.org/project/drupal/issues/2978575#comment-13915246 β†’

Steps to reproduce

Try Azure MySQL service.

Proposed resolution

πŸ“Œ Task
Status

Fixed

Version

7.0 ⚰️

Component
BaseΒ  β†’

Last updated about 1 hour ago

Created by

πŸ‡·πŸ‡ΈSerbia SAVEL

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024