Change record status: 
Project: 
Introduced in branch: 
9.4.x
Introduced in version: 
9.4.0
Description: 

Previously support was added for contrib database drivers to be in the module's namespace and "src" directory. See https://www.drupal.org/node/3123251. We are now using that functionality to move the by core supported database drivers (MySQL, PostgreSQL and SQLite) to their own module. For each database driver is a new core module created.

For database drivers in a module's namespace (as opposed to in Drupal\Driver or Drupal\Core), a module query parameter is added to the database connection URL. For example: pgsql://test_user:test_pass@test_host:5432/test_database?module=pgsql. When using one of the by core supported database drivers, the adding of the module name is not required. The old connection URL's will keep working.

Use-statement to database driver classes

Using the use statement with database driver specific classes in the namespace Drupal\Core\Database\Driver have been deprecated and will be removed before the release of Drupal 11.0.0. The best is to replace them with references to the generic class on which the driver class is based. Like:

  • use Drupal\Core\Database\Driver\{mysql|pgsql|sqlite}\Install\Tasks should now be replaced by use Drupal\Core\Database\Install\Tasks
  • use Drupal\Core\Database\Driver\{mysql|pgsql|sqlite}\Connection should now be replaced by use Drupal\Core\Database\Connection
  • use Drupal\Core\Database\Driver\{mysql|pgsql|sqlite}\Delete should now be replaced by use Drupal\Core\Database\Query\Delete
  • use Drupal\Core\Database\Driver\{mysql|pgsql|sqlite}\ExceptionHandler should now be replaced by use Drupal\Core\Database\ExceptionHandler
  • use Drupal\Core\Database\Driver\{mysql|pgsql|sqlite}\Insert should now be replaced by use Drupal\Core\Database\Query\Insert
  • use Drupal\Core\Database\Driver\{mysql|pgsql|sqlite}\Schema should now be replaced by use Drupal\Core\Database\Schema
  • use Drupal\Core\Database\Driver\{mysql|pgsql|sqlite}\Select should now be replaced by use Drupal\Core\Database\Query\Select
  • use Drupal\Core\Database\Driver\{mysql|pgsql|sqlite}\Truncate should now be replaced by use Drupal\Core\Database\Query\Truncate
  • use Drupal\Core\Database\Driver\{mysql|pgsql|sqlite}\Update should now be replaced by use Drupal\Core\Database\Query\Update
  • use Drupal\Core\Database\Driver\{mysql|pgsql|sqlite}\Upsert should now be replaced by use Drupal\Core\Database\Query\Upsert
Impacts: 
Site builders, administrators, editors
Module developers
Distribution developers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other: 
Other updates done

Comments

ccjjmartin’s picture

When upgrading to 9.4 my custom modules are having to implement this now. So this appears to have been implemented as a breaking change instead of a deprecation to be removed later. Specifically the error I am getting is:

EntityUsage::__construct() must be an instance of Drupal\Core\Database\Driver\mysql\Connection, instance of Drupal\mysql\Driver\Database\mysql\Connection given

In my services.yml file the services just referenced @database as the argument.