Introduce database driver extensions and autoload database drivers' dependencies

Created on 2 January 2022, over 2 years ago
Updated 27 August 2023, 10 months ago

Problem/Motivation

Database drivers that extend another database driver have to add the line with something like: include_once dirname(__DIR__, 8) . '/mysql/src/Driver/Database/mysql/Connection.php';. When this line is not added, the database driver will fail the installation proces. The extending database driver is then using a class that is not autoloaded and therefor does not exist.
The include_once only works when the module with the extending database driver is in the same level in the directory structure. This is not very practical for sitebuilders. It is also not to the standard Drupal Core would like its code to be.
Example database drivers that extend another database driver are: https://www.drupal.org/project/mysql56 and https://www.drupal.org/project/pgsql_fallback .

Proposed resolution

Improve the autoloading for database drivers that are dependent on another database driver. Add extension for database drivers and lists of database drivers.

Improve the autoloading for the parent database driver during installation.

Remaining tasks

TBD

User interface changes

None

API changes

The function drupal_get_database_types() has been deprecated and is being replaced by \Drupal::service('extension.list.database_driver')->getInstallableList();.

The function drupal_detect_database_types() has been deprecated and is being replaced by \Drupal::service('extension.list.database_driver')->getInstallableList();.

The method Drupal\Core\Database\Database::findDriverAutoloadDirectory() has been deprecated and is being replaced by \Drupal::service('extension.list.database_driver')->get($namespace)->getAutoloadInfo().

Extensions for database drivers have been added.

The service for getting a database driver or a list of database drivers is \Drupal::service('extension.list.database_driver').

Data model changes

None

Release notes snippet

TBD

Feature request
Status

Fixed

Version

11.0 🔥

Component
Database 

Last updated 1 day ago

  • Maintained by
  • 🇳🇱Netherlands @daffie
Created by

🇳🇱Netherlands daffie

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