Skip to content
Snippets Groups Projects
Unverified Commit 8fd18feb authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3450706 by daffie, smustgrave, alexpott, quietone, mondrake: Let for...

Issue #3450706 by daffie, smustgrave, alexpott, quietone, mondrake: Let for all database drivers the module name setting default to the driver name
parent c9c39665
No related branches found
No related tags found
12 merge requests!11197Issue #3506427 by eduardo morales alberti: Remove responsive_image.ajax from hook,!11131[10.4.x-only-DO-NOT-MERGE]: Issue ##2842525 Ajax attached to Views exposed filter form does not trigger callbacks,!10786Issue #3490579 by shalini_jha, mstrelan: Add void return to all views...,!5423Draft: Resolve #3329907 "Test2",!3878Removed unused condition head title for views,!3818Issue #2140179: $entity->original gets stale between updates,!3478Issue #3337882: Deleted menus are not removed from content type config,!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!2062Issue #3246454: Add weekly granularity to views date sort,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!579Issue #2230909: Simple decimals fail to pass validation,!213Issue #2906496: Give Media a menu item under Content
Pipeline #371389 passed with warnings
Pipeline: drupal

#371393

    ......@@ -521,16 +521,11 @@ public static function convertDbUrlToConnectionInfo($url, $root, ?bool $include_
    $url_component_query = $url_components['query'] ?? '';
    parse_str($url_component_query, $query);
    // Add the module key for core database drivers when the module key is not
    // set.
    if (!isset($query['module']) && in_array($driverName, ['mysql', 'pgsql', 'sqlite'], TRUE)) {
    $query['module'] = $driverName;
    }
    if (!isset($query['module'])) {
    throw new \InvalidArgumentException("Can not convert '$url' to a database connection, the module providing the driver '{$driverName}' is not specified");
    }
    // Use the driver name as the module name when the module name is not
    // provided.
    $module = $query['module'] ?? $driverName;
    $driverNamespace = "Drupal\\{$query['module']}\\Driver\\Database\\{$driverName}";
    $driverNamespace = "Drupal\\{$module}\\Driver\\Database\\{$driverName}";
    /** @var \Drupal\Core\Extension\DatabaseDriver $driver */
    $driver = self::getDriverList()
    ......
    name: 'DummyDB'
    type: module
    description: 'Fake database driver for DummyDB.'
    package: Testing
    version: VERSION
    dependencies:
    - drupal:mysql
    <?php
    declare(strict_types=1);
    // cspell:ignore dummydb
    namespace Drupal\dummydb\Driver\Database\dummydb;
    use Drupal\mysql\Driver\Database\mysql\Connection as CoreConnection;
    /**
    * DummyDB test implementation of \Drupal\Core\Database\Connection.
    */
    class Connection extends CoreConnection {
    /**
    * {@inheritdoc}
    */
    public function driver() {
    return 'dummydb';
    }
    /**
    * {@inheritdoc}
    */
    public function databaseType() {
    return 'dummydb';
    }
    }
    <?php
    declare(strict_types=1);
    // cspell:ignore dummydb
    namespace Drupal\dummydb\Driver\Database\dummydb\Install;
    use Drupal\mysql\Driver\Database\mysql\Install\Tasks as CoreTasks;
    /**
    * Specifies installation tasks for DummyDB test database.
    */
    class Tasks extends CoreTasks {
    /**
    * {@inheritdoc}
    */
    public function name() {
    return t('DummyDB');
    }
    }
    ......@@ -8,6 +8,8 @@
    use Drupal\Core\Extension\Exception\UnknownExtensionException;
    use Drupal\Tests\UnitTestCase;
    // cspell:ignore dummydb
    /**
    * Tests for database URL to/from database connection array conversions.
    *
    ......@@ -297,14 +299,34 @@ public static function providerInvalidArgumentsUrlConversion() {
    return [
    ['foo', '', "Missing scheme in URL 'foo'"],
    ['foo', 'bar', "Missing scheme in URL 'foo'"],
    ['foo://', 'bar', "Can not convert 'foo://' to a database connection, the module providing the driver 'foo' is not specified"],
    ['foo://bar', 'baz', "Can not convert 'foo://bar' to a database connection, the module providing the driver 'foo' is not specified"],
    ['foo://bar:port', 'baz', "Can not convert 'foo://bar:port' to a database connection, the module providing the driver 'foo' is not specified"],
    ['foo/bar/baz', 'bar2', "Missing scheme in URL 'foo/bar/baz'"],
    ['foo://bar:baz@test1', 'test2', "Can not convert 'foo://bar:baz@test1' to a database connection, the module providing the driver 'foo' is not specified"],
    ];
    }
    /**
    * Tests that connection URL with no module name defaults to driver name.
    */
    public function testNoModuleSpecifiedDefaultsToDriverName(): void {
    $url = 'dummydb://test_user:test_pass@test_host/test_database';
    $connection_info = Database::convertDbUrlToConnectionInfo($url, $this->root, TRUE);
    $expected = [
    'driver' => 'dummydb',
    'username' => 'test_user',
    'password' => 'test_pass',
    'host' => 'test_host',
    'database' => 'test_database',
    'namespace' => 'Drupal\dummydb\Driver\Database\dummydb',
    'autoload' => 'core/modules/system/tests/modules/dummydb/src/Driver/Database/dummydb/',
    'dependencies' => [
    'mysql' => [
    'namespace' => 'Drupal\mysql',
    'autoload' => 'core/modules/mysql/src/',
    ],
    ],
    ];
    $this->assertSame($expected, $connection_info);
    }
    /**
    * @covers ::getConnectionInfoAsUrl
    *
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment