diff --git a/core/lib/Drupal/Core/Database/Database.php b/core/lib/Drupal/Core/Database/Database.php index 55f3501..009cef9 100644 --- a/core/lib/Drupal/Core/Database/Database.php +++ b/core/lib/Drupal/Core/Database/Database.php @@ -449,11 +449,13 @@ public static function ignoreTarget($key, $target) { * * @param string $url * The URL. + * @param string $root + * The root directory of the Drupal installation. * * @return array * The database connection info. */ - public static function convertDbUrlToConnectionInfo($url) { + public static function convertDbUrlToConnectionInfo($url, $root) { $info = parse_url($url); if (!isset($info['scheme'], $info['host'], $info['path'])) { throw new \InvalidArgumentException('Invalid --dburl. Minimum requirement: driver://host/database.'); @@ -467,7 +469,7 @@ public static function convertDbUrlToConnectionInfo($url) { $info['path'] = substr($info['path'], 1); } if ($info['scheme'] === 'sqlite' && $info['path'][0] !== '/') { - $info['path'] = DRUPAL_ROOT . '/' . $info['path']; + $info['path'] = $root . '/' . $info['path']; } $database = array( 'driver' => $info['scheme'], diff --git a/core/modules/simpletest/src/BrowserTestBase.php b/core/modules/simpletest/src/BrowserTestBase.php index c8aa69b..c0cd5fe 100644 --- a/core/modules/simpletest/src/BrowserTestBase.php +++ b/core/modules/simpletest/src/BrowserTestBase.php @@ -1064,7 +1064,7 @@ private function changeDatabasePrefix() { // If the test is run with argument dburl then use it. $db_url = getenv('SIMPLETEST_DB'); if (!empty($db_url)) { - $database = Database::convertDbUrlToConnectionInfo($db_url); + $database = Database::convertDbUrlToConnectionInfo($db_url, DRUPAL_ROOT); Database::addConnectionInfo('default', 'default', $database); } diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh index 209e237..5f4d35a 100644 --- a/core/scripts/run-tests.sh +++ b/core/scripts/run-tests.sh @@ -414,7 +414,7 @@ function simpletest_script_setup_database($new = FALSE) { // Remove a possibly existing default connection (from settings.php). Database::removeConnection('default'); try { - $databases['default']['default'] = Database::convertDbUrlToConnectionInfo($args['dburl']); + $databases['default']['default'] = Database::convertDbUrlToConnectionInfo($args['dburl'], DRUPAL_ROOT); } catch (\InvalidArgumentException $e) { simpletest_script_print_error('Invalid --dburl. Reason: ' . $e->getMessage());