Skip to content

Commit c91c592

Browse files
committed
Issue #3056698 by mondrake, quietone: Sqlite Connection::createConnectionOptionsFromUrl should not convert relative paths to full
1 parent 80ada4f commit c91c592

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

modules/sqlite/src/Driver/Database/sqlite/Connection.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -445,12 +445,7 @@ public static function createConnectionOptionsFromUrl($url, $root) {
445445
if ($url_components['path'][0] === '/') {
446446
$url_components['path'] = substr($url_components['path'], 1);
447447
}
448-
if ($url_components['path'][0] === '/' || $url_components['path'] === ':memory:') {
449-
$database['database'] = $url_components['path'];
450-
}
451-
else {
452-
$database['database'] = $root . '/' . $url_components['path'];
453-
}
448+
$database['database'] = $url_components['path'];
454449

455450
// User credentials and system port are irrelevant for SQLite.
456451
unset(

modules/sqlite/tests/src/Unit/ConnectionTest.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ public function testCreateConnectionOptionsFromUrl(string $url, string $expected
4040
* - Expected database connection option
4141
*/
4242
public static function providerCreateConnectionOptionsFromUrl(): array {
43-
$root = dirname(__DIR__, 8);
4443
return [
45-
'sqlite relative path' => ['sqlite://localhost/tmp/test', $root . '/tmp/test'],
44+
'sqlite relative path' => ['sqlite://localhost/tmp/test', 'tmp/test'],
4645
'sqlite absolute path' => ['sqlite://localhost//tmp/test', '/tmp/test'],
4746
'in memory sqlite path' => ['sqlite://localhost/:memory:', ':memory:'],
4847
];

tests/Drupal/Tests/Core/Database/UrlConversionTest.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ public function testDbUrlToConnectionConversion($url, $database_array, $include_
4444
* - database_array: An array containing the expected results.
4545
*/
4646
public static function providerConvertDbUrlToConnectionInfo() {
47-
$root = dirname(__FILE__, 7);
4847
return [
4948
'MySql without prefix' => [
5049
'mysql://test_user:test_pass@test_host:3306/test_database',
@@ -65,7 +64,7 @@ public static function providerConvertDbUrlToConnectionInfo() {
6564
[
6665
'driver' => 'sqlite',
6766
'host' => 'localhost',
68-
'database' => $root . '/test_database',
67+
'database' => 'test_database',
6968
'namespace' => 'Drupal\sqlite\Driver\Database\sqlite',
7069
'autoload' => 'core/modules/sqlite/src/Driver/Database/sqlite/',
7170
],
@@ -91,7 +90,7 @@ public static function providerConvertDbUrlToConnectionInfo() {
9190
[
9291
'driver' => 'sqlite',
9392
'host' => 'localhost',
94-
'database' => $root . '/test_database',
93+
'database' => 'test_database',
9594
'prefix' => 'foo',
9695
'namespace' => 'Drupal\sqlite\Driver\Database\sqlite',
9796
'autoload' => 'core/modules/sqlite/src/Driver/Database/sqlite/',
@@ -266,7 +265,7 @@ public static function providerConvertDbUrlToConnectionInfo() {
266265
[
267266
'driver' => 'sqlite',
268267
'host' => 'localhost',
269-
'database' => $root . '/test_database',
268+
'database' => 'test_database',
270269
'namespace' => 'Drupal\sqlite\Driver\Database\sqlite',
271270
'autoload' => 'core/modules/sqlite/src/Driver/Database/sqlite/',
272271
],

0 commit comments

Comments
 (0)