Skip to content

Commit

Permalink
Issue #3126940 by Beakerboy, daffie: New DB URI breaks if an existing…
Browse files Browse the repository at this point in the history
… query part is missing the new module parameter

(cherry picked from commit d6f9e2c401a21c99792b0a4ceec8cd8c23f7d1b9)
  • Loading branch information
catch committed Apr 14, 2020
1 parent 01ef2d1 commit be1a0ff
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Drupal/Core/Database/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ public static function convertDbUrlToConnectionInfo($url, $root) {
$url_components = parse_url($url);
if (isset($url_components['query'])) {
parse_str($url_components['query'], $query);
if ($query['module']) {
if (isset($query['module']) && $query['module']) {
$module = $query['module'];
// Set up an additional autoloader. We don't use the main autoloader as
// this method can be called before Drupal is installed and is never
Expand Down
13 changes: 13 additions & 0 deletions tests/Drupal/Tests/Core/Database/UrlConversionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,19 @@ public function providerConvertDbUrlToConnectionInfo() {
'autoload' => 'core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestPgsql/',
],
],
'MySql with a custom query parameter' => [
'',
'mysql://test_user:test_pass@test_host:3306/test_database?extra=value',
[
'driver' => 'mysql',
'username' => 'test_user',
'password' => 'test_pass',
'host' => 'test_host',
'database' => 'test_database',
'port' => 3306,
'namespace' => 'Drupal\Core\Database\Driver\mysql',
],
],
];
}

Expand Down

0 comments on commit be1a0ff

Please sign in to comment.