DatabaseDriver::load should have a non-service alternative for class loading

Created on 9 March 2024, 3 months ago
Updated 5 April 2024, 2 months ago

Problem/Motivation

Database drivers should be reachable even if no container is available.

This code in database caters for that

  /**
   * Returns the list provider for available database drivers.
   *
   * @return \Drupal\Core\Extension\DatabaseDriverList
   *   The list provider for available database drivers.
   */
  public static function getDriverList(): DatabaseDriverList {
    if (\Drupal::hasContainer() && \Drupal::hasService('extension.list.database_driver')) {
      return \Drupal::service('extension.list.database_driver');
    }
    else {
      return new DatabaseDriverList(DRUPAL_ROOT, 'database_driver', new NullBackend('database_driver'));
    }
  }

but the non-service alternative is failed later when DatabaseDriver::load() tries to access the class_loader service.

Steps to reproduce

Found this while trying to adjust Drush's interactive site:install command, that runs when no db-url option is passed in.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Fixed

Version

10.2

Component
Extension 

Last updated 3 days ago

No maintainer
Created by

🇮🇹Italy mondrake 🇮🇹

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

Merge Requests

Comments & Activities

Production build 0.69.0 2024