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

Issue #3056698 by mondrake, quietone: Sqlite...

Issue #3056698 by mondrake, quietone: Sqlite Connection::createConnectionOptionsFromUrl should not convert relative paths to full

(cherry picked from commit 868e8468)
parent 77e42bc1
No related branches found
No related tags found
12 merge requests!12227Issue #3181946 by jonmcl, mglaman,!12079Issue #3523476 by matthiasm11: Add empty check on operator,!12024Fix: DocBlock comment for return value of Drupal\Core\Database\Connection::transactionManager(),!11974Draft: Issue #3495165 by catch, joeyroth, berdir, texas-bronius: Better warning...,!11934Issue #3520997: DefaultLazyPluginCollection unnecessarily instantiates plugins when sorting collection,!11887Issue #3520065: The migrate Row class API is incomplete,!11636Draft: Issue #3515643 by macsim: fieldNameExists method is inconsistent,!11515Issue #3480419 by mondrake, smustgrave, catch: Method...,!11380Issue #3490698 by catch, spokje: Bump MINIMUM_STABILITY back to 'stable' when...,!11281Use Drupal Core Leadership terminology in MAINTAINERS.txt,!11239Issue #3507548: Allow workspace changes listing to show all items, without a pager,!11238Fix issue #3051797
Pipeline #424590 canceled
...@@ -433,12 +433,7 @@ public static function createConnectionOptionsFromUrl($url, $root) { ...@@ -433,12 +433,7 @@ public static function createConnectionOptionsFromUrl($url, $root) {
if ($url_components['path'][0] === '/') { if ($url_components['path'][0] === '/') {
$url_components['path'] = substr($url_components['path'], 1); $url_components['path'] = substr($url_components['path'], 1);
} }
if ($url_components['path'][0] === '/' || $url_components['path'] === ':memory:') {
$database['database'] = $url_components['path']; $database['database'] = $url_components['path'];
}
else {
$database['database'] = $root . '/' . $url_components['path'];
}
// User credentials and system port are irrelevant for SQLite. // User credentials and system port are irrelevant for SQLite.
unset( unset(
......
...@@ -40,9 +40,8 @@ public function testCreateConnectionOptionsFromUrl(string $url, string $expected ...@@ -40,9 +40,8 @@ public function testCreateConnectionOptionsFromUrl(string $url, string $expected
* - Expected database connection option * - Expected database connection option
*/ */
public static function providerCreateConnectionOptionsFromUrl(): array { public static function providerCreateConnectionOptionsFromUrl(): array {
$root = dirname(__DIR__, 8);
return [ return [
'sqlite relative path' => ['sqlite://localhost/tmp/test', $root . '/tmp/test'], 'sqlite relative path' => ['sqlite://localhost/tmp/test', 'tmp/test'],
'sqlite absolute path' => ['sqlite://localhost//tmp/test', '/tmp/test'], 'sqlite absolute path' => ['sqlite://localhost//tmp/test', '/tmp/test'],
'in memory sqlite path' => ['sqlite://localhost/:memory:', ':memory:'], 'in memory sqlite path' => ['sqlite://localhost/:memory:', ':memory:'],
]; ];
......
...@@ -42,7 +42,6 @@ public function testDbUrlToConnectionConversion($url, $database_array, $include_ ...@@ -42,7 +42,6 @@ public function testDbUrlToConnectionConversion($url, $database_array, $include_
* - database_array: An array containing the expected results. * - database_array: An array containing the expected results.
*/ */
public static function providerConvertDbUrlToConnectionInfo() { public static function providerConvertDbUrlToConnectionInfo() {
$root = dirname(__FILE__, 7);
return [ return [
'MySql without prefix' => [ 'MySql without prefix' => [
'mysql://test_user:test_pass@test_host:3306/test_database', 'mysql://test_user:test_pass@test_host:3306/test_database',
...@@ -63,7 +62,7 @@ public static function providerConvertDbUrlToConnectionInfo() { ...@@ -63,7 +62,7 @@ public static function providerConvertDbUrlToConnectionInfo() {
[ [
'driver' => 'sqlite', 'driver' => 'sqlite',
'host' => 'localhost', 'host' => 'localhost',
'database' => $root . '/test_database', 'database' => 'test_database',
'namespace' => 'Drupal\sqlite\Driver\Database\sqlite', 'namespace' => 'Drupal\sqlite\Driver\Database\sqlite',
'autoload' => 'core/modules/sqlite/src/Driver/Database/sqlite/', 'autoload' => 'core/modules/sqlite/src/Driver/Database/sqlite/',
], ],
...@@ -89,7 +88,7 @@ public static function providerConvertDbUrlToConnectionInfo() { ...@@ -89,7 +88,7 @@ public static function providerConvertDbUrlToConnectionInfo() {
[ [
'driver' => 'sqlite', 'driver' => 'sqlite',
'host' => 'localhost', 'host' => 'localhost',
'database' => $root . '/test_database', 'database' => 'test_database',
'prefix' => 'foo', 'prefix' => 'foo',
'namespace' => 'Drupal\sqlite\Driver\Database\sqlite', 'namespace' => 'Drupal\sqlite\Driver\Database\sqlite',
'autoload' => 'core/modules/sqlite/src/Driver/Database/sqlite/', 'autoload' => 'core/modules/sqlite/src/Driver/Database/sqlite/',
...@@ -264,7 +263,7 @@ public static function providerConvertDbUrlToConnectionInfo() { ...@@ -264,7 +263,7 @@ public static function providerConvertDbUrlToConnectionInfo() {
[ [
'driver' => 'sqlite', 'driver' => 'sqlite',
'host' => 'localhost', 'host' => 'localhost',
'database' => $root . '/test_database', 'database' => 'test_database',
'namespace' => 'Drupal\sqlite\Driver\Database\sqlite', 'namespace' => 'Drupal\sqlite\Driver\Database\sqlite',
'autoload' => 'core/modules/sqlite/src/Driver/Database/sqlite/', 'autoload' => 'core/modules/sqlite/src/Driver/Database/sqlite/',
], ],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment