Fix deprecation issue for the mysql driver on Drupal 9.4.0

Created on 16 June 2022, over 2 years ago
Updated 15 April 2023, over 1 year ago

Problem/Motivation

Drupal 9.4.0 stable was released on 15 Jun 2022 at 19:35 EEST by: xjm β†’
https://www.drupal.org/project/drupal/releases/9.4.0 β†’
Thank you, Jess

#3129043: Move core database drivers to modules of their own β†’

Steps to reproduce

After a new build and new drush site:install for a new site ( not on update )

mkdir -p /var/www/html/dev
cd /var/www/html/dev/
composer create-project drupal/recommended-project d940x1 -vvv
cd /var/www/html/dev/d940x1/
composer require drush/drush
cd /var/www/html/dev/d940x1/web
../vendor/drush/drush/drush site:install standard --yes --account-name="webmaster" --account-pass="dD.123123ddd" --account-mail="webmaster@example.com" --db-url="mysql://root:rootpw@127.0.0.1/test_varbase" --locale="en"
composer require 'drupal/content_planner:^1.0@beta'
../vendor/drush/drush/drush pm:enable content_planner
../vendor/drush/drush/drush pm:enable content_kanban
../vendor/drush/drush/drush cr

Trying to do any other drush commands like
../vendor/drush/drush/drush user-create newuser --mail="person@example.com" --password="dD.123123ddd"

Facing issues with a number of contrib modules

[error]  TypeError: ############ Argument #1 ($database) must be of type Drupal\Core\Database\Driver\mysql\Connection, Drupal\mysql\Driver\Database\mysql\Connection given

But the Drupal\Core\Database\Driver\mysql\Connection is used not the Drupal\mysql\Driver\Database\mysql\Connection

And the message from the Mysql Driver Legacy Test

\\Drupal\\Core\\Database\\Driver\\mysql\\Connection is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The MySQL database driver has been moved to the mysql module. See https://www.drupal.org/node/3129492'

The MySQL module

 drush en mysql
 [notice] Already enabled: MySQL

Proposed resolution

Change from Drupal\Core\Database\Driver\mysql\Connection to Drupal\mysql\Driver\Database\mysql\Connection

Remaining tasks

  • Fix patch
  • Test Install
  • Test on update
  • Review
  • Commit
  • Release

User interface changes

  • N/A

API changes

  • N/A

Data model changes

  • N/A
πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡―πŸ‡΄Jordan Rajab Natshah Jordan

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.

  • πŸ‡ΊπŸ‡¦Ukraine aev_fly

    I also got the error
    Error: Undefined constant PDO::MYSQL_ATTR_DIRECT_QUERY in /core/modules/mysql/src/Driver/Database/mysql/Connection.php on line 172
    the reason was not enabled extension pdo_mysql in php 8.0
    check your extension pdo_mysql

Production build 0.71.5 2024