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
Loading
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -433,12 +433,7 @@ public static function createConnectionOptionsFromUrl($url, $root) {
    if ($url_components['path'][0] === '/') {
      $url_components['path'] = substr($url_components['path'], 1);
    }
    if ($url_components['path'][0] === '/' || $url_components['path'] === ':memory:') {
    $database['database'] = $url_components['path'];
    }
    else {
      $database['database'] = $root . '/' . $url_components['path'];
    }

    // User credentials and system port are irrelevant for SQLite.
    unset(
+1 −2
Original line number Diff line number Diff line
@@ -40,9 +40,8 @@ public function testCreateConnectionOptionsFromUrl(string $url, string $expected
   *   - Expected database connection option
   */
  public static function providerCreateConnectionOptionsFromUrl(): array {
    $root = dirname(__DIR__, 8);
    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'],
      'in memory sqlite path' => ['sqlite://localhost/:memory:', ':memory:'],
    ];
+3 −4
Original line number Diff line number Diff line
@@ -42,7 +42,6 @@ public function testDbUrlToConnectionConversion($url, $database_array, $include_
   *   - database_array: An array containing the expected results.
   */
  public static function providerConvertDbUrlToConnectionInfo() {
    $root = dirname(__FILE__, 7);
    return [
      'MySql without prefix' => [
        'mysql://test_user:test_pass@test_host:3306/test_database',
@@ -63,7 +62,7 @@ public static function providerConvertDbUrlToConnectionInfo() {
        [
          'driver' => 'sqlite',
          'host' => 'localhost',
          'database' => $root . '/test_database',
          'database' => 'test_database',
          'namespace' => 'Drupal\sqlite\Driver\Database\sqlite',
          'autoload' => 'core/modules/sqlite/src/Driver/Database/sqlite/',
        ],
@@ -89,7 +88,7 @@ public static function providerConvertDbUrlToConnectionInfo() {
        [
          'driver' => 'sqlite',
          'host' => 'localhost',
          'database' => $root . '/test_database',
          'database' => 'test_database',
          'prefix' => 'foo',
          'namespace' => 'Drupal\sqlite\Driver\Database\sqlite',
          'autoload' => 'core/modules/sqlite/src/Driver/Database/sqlite/',
@@ -264,7 +263,7 @@ public static function providerConvertDbUrlToConnectionInfo() {
        [
          'driver' => 'sqlite',
          'host' => 'localhost',
          'database' => $root . '/test_database',
          'database' => 'test_database',
          'namespace' => 'Drupal\sqlite\Driver\Database\sqlite',
          'autoload' => 'core/modules/sqlite/src/Driver/Database/sqlite/',
        ],