Problem/Motivation
The current situation is the all contrib database driver directories must be copied to the directory DRUPAL_ROOT/drivers
. This must be done because it is the only location that Drupal core looks in for contrib drivers.
The Drupal project is switching to the use of the composer tool and copying driver directories is very bad for the workflow with composer.
The current workflow with contrib database drivers is as follows
There are 2 kinds of contrib database drivers:
- the first has only a driver directory. Lets call them type A;
- the second one has a driver directory and a module part. Lets call those type B.
I am working on creating a fallback driver for PostgreSQL and lets take that as an example. At the moment it only has a driver directory and therefor its a type A. When the by core supported driver for PostgreSQL starts using the pg_trgm extension, the contrib driver will need to undo that and therefor needs a module part and becomes a contrib driver of type B.
The workflow of installing a contrib database driver
Installing the contrib driver is as follows:
1. Download/require the contrib driver;
2. Copy the contents of the "drivers" directory from the module to the root of the Drupal project/installation.
3. If the contrib driver has a module part, the module must be enabled.
I am not sure when working with composer if this can be automated from the contrib driver or does the site builder/owner has to use scaffolding in their composer.json to copy the "drivers" directory them self.
The workflow of updating a contrib database driver
Updating the contrib driver is as follows:
1. Downloading the updated contrib driver;
2. Copy the contents of the "drivers" directory from the module to the root of the Drupal project/installation and replacing the existing one.
3. Running the site updates script.
Site builders/owner are not used to coping files after they have run the command composer update. If they forget they will still be working with the old version of the driver directory. If they have a type B contrib driver they will be using 2 different versions. One for the driver directory and one for the module part of the contrib driver. If a site builder/owner runs the update script before copying the update to the "drivers" directory, a lot can go wrong.
The workflow of moving from using a contrib driver to using a by core supported driver
Moving to using the by core supported driver (with the current patch):
1. Running the update process that will be provided by the contrib driver (creating the pg_trgm indexes);
2. Deleting the contents of the "drivers" directory in the root of the Drupal project/installation;
3. Disabling the contrib module (if type B).
Testing the transition is for a site builder/owner not very easy to do.
If somebody wants to know if a site is using a contrib driver, the only way to check for that is looking if the "drivers" directory in the root of the Drupal project/installation is used or not. The driver setting in the settings.php will be the same for contrib and the by core supported drivers.
Moving to using the by core supported driver (without the current patch):
1. Running the update process that will be provided by the contrib driver (creating the pg_trgm indexes);
2. Change the driver setting from "pgsql-fallback" to "pgsql" in the settings.php file.
Proposed resolution
The basic solution as it was proposed by @alexpott is as follows:
- Make every contrib database driver a module;
- Within that module have default location where the driver directory must be. a.k.a. that is where Drupal core will look for it. The suggested default location would be src/Driver
. It can be because we are looking for the existence of the file src/Driver/Install/Tasks.php
Remaining tasks
(reviews needed, tests to be written or run, documentation to be written, etc.)
User interface changes
None
API changes
(API changes/additions that would affect module, install profile, and theme developers, including examples of before/after code if appropriate.)
Data model changes
None
Release notes snippet