Skip to content
Snippets Groups Projects

Always default the module name setting for database driver to their driver name

Closes #3450706

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
297 297 return [
298 298 ['foo', '', "Missing scheme in URL 'foo'"],
299 299 ['foo', 'bar', "Missing scheme in URL 'foo'"],
300 ['foo://', 'bar', "Can not convert 'foo://' to a database connection, the module providing the driver 'foo' is not specified"],
301 ['foo://bar', 'baz', "Can not convert 'foo://bar' to a database connection, the module providing the driver 'foo' is not specified"],
302 ['foo://bar:port', 'baz', "Can not convert 'foo://bar:port' to a database connection, the module providing the driver 'foo' is not specified"],
303 300 ['foo/bar/baz', 'bar2', "Missing scheme in URL 'foo/bar/baz'"],
304 ['foo://bar:baz@test1', 'test2', "Can not convert 'foo://bar:baz@test1' to a database connection, the module providing the driver 'foo' is not specified"],
305 301 ];
306 302 }
307 303
304 /**
305 * Tests that the exception for having no module setting is not thrown.
306 */
307 public function testNoModuleIsSpecifiedExceptionIsRemoved() {
  • added 1 commit

    • bc981274 - Apply 1 suggestion(s) to 1 file(s)

    Compare with previous version

  • daffie added 522 commits

    added 522 commits

    Compare with previous version

  • daffie added 1 commit

    added 1 commit

    Compare with previous version

  • 521 521 $url_component_query = $url_components['query'] ?? '';
    522 522 parse_str($url_component_query, $query);
    523 523
    524 // Add the module key for core database drivers when the module key is not
    525 // set.
    526 if (!isset($query['module']) && in_array($driverName, ['mysql', 'pgsql', 'sqlite'], TRUE)) {
    527 $query['module'] = $driverName;
    528 }
    524 // Add the module key for database drivers when the module key is not set.
    529 525 if (!isset($query['module'])) {
    530 throw new \InvalidArgumentException("Can not convert '$url' to a database connection, the module providing the driver '{$driverName}' is not specified");
    526 $query['module'] = $driverName;
    531 527 }
    532 528
    533 529 $driverNamespace = "Drupal\\{$query['module']}\\Driver\\Database\\{$driverName}";
    • Comment on lines +524 to 529

      I think we can improve the comment and amount of logic / readability here.

      Suggested change
      524 // Add the module key for database drivers when the module key is not set.
      525 if (!isset($query['module'])) {
      526 $query['module'] = $driverName;
      527 }
      528
      529 $driverNamespace = "Drupal\\{$query['module']}\\Driver\\Database\\{$driverName}";
      524 // Use the driver name as the module name if module is not provided.
      525 $module = $query['module'] ?? $driverName;
      526
      527 $driverNamespace = "Drupal\\{$module}\\Driver\\Database\\{$driverName}";
    • changed this line in version 6 of the diff

    • Please register or sign in to reply
  • 297 299 return [
    298 300 ['foo', '', "Missing scheme in URL 'foo'"],
    299 301 ['foo', 'bar', "Missing scheme in URL 'foo'"],
    300 ['foo://', 'bar', "Can not convert 'foo://' to a database connection, the module providing the driver 'foo' is not specified"],
    301 ['foo://bar', 'baz', "Can not convert 'foo://bar' to a database connection, the module providing the driver 'foo' is not specified"],
    302 ['foo://bar:port', 'baz', "Can not convert 'foo://bar:port' to a database connection, the module providing the driver 'foo' is not specified"],
    303 302 ['foo/bar/baz', 'bar2', "Missing scheme in URL 'foo/bar/baz'"],
    304 ['foo://bar:baz@test1', 'test2', "Can not convert 'foo://bar:baz@test1' to a database connection, the module providing the driver 'foo' is not specified"],
    305 303 ];
    306 304 }
    307 305
    306 /**
    307 * Tests that the exception for having no module setting is not thrown.
    308 */
    309 public function testNoModuleIsSpecifiedExceptionIsRemoved(): void {
  • daffie added 231 commits

    added 231 commits

    Compare with previous version

  • daffie added 1 commit

    added 1 commit

    • e170137f - Updated the fix and the testing as requested

    Compare with previous version

  • daffie added 1 commit

    added 1 commit

    • 46d819e0 - Added the right dummydb database driver and removed the wrong one.

    Compare with previous version

  • daffie added 1 commit

    added 1 commit

    • 09e0971f - Updated the dummydb database driver for style guide violations

    Compare with previous version

  • daffie added 1 commit

    added 1 commit

    Compare with previous version

  • daffie added 1 commit

    added 1 commit

    • d2bcd63d - Updated driver name to dummydb

    Compare with previous version

  • daffie added 1 commit

    added 1 commit

    • d98220de - Updated the DummyDB install takss class

    Compare with previous version

  • daffie added 1 commit

    added 1 commit

    • 9b4ae34c - Updated the DummyDB Install Tasks class

    Compare with previous version

  • daffie added 1 commit

    added 1 commit

    Compare with previous version

  • daffie added 1 commit

    added 1 commit

    • 57429a43 - Moved the cspell exception to the top of the file

    Compare with previous version

  • daffie added 1 commit

    added 1 commit

    • 2d7e9206 - 2 added dummy classes for fixing the PHPStan errors

    Compare with previous version

  • daffie added 1 commit

    added 1 commit

    • c4c7af1c - Fixed style guide violations

    Compare with previous version

  • daffie added 1 commit

    added 1 commit

    • 15e34342 - Fixed style guide violations

    Compare with previous version

  • daffie added 1 commit

    added 1 commit

    • db8a65ee - Added the abstract methods to DummyDB Schema

    Compare with previous version

  • daffie added 1 commit

    added 1 commit

    • 4ce11cd1 - Added the abstract methods to DummyDB Upsert

    Compare with previous version

  • daffie added 1 commit

    added 1 commit

    • 4189f5d5 - Fixed another style guide violation

    Compare with previous version

  • 8 use Drupal\Core\Database\ExceptionHandler;
    9 use Drupal\Core\Database\Query\Condition;
    10 use Drupal\Core\Database\Query\Delete;
    11 use Drupal\Core\Database\Query\Insert;
    12 use Drupal\Core\Database\Query\Merge;
    13 use Drupal\Core\Database\Query\Select;
    14 use Drupal\Core\Database\Query\Truncate;
    15 use Drupal\Core\Database\Query\Update;
    16 use Drupal\Core\Database\StatementWrapperIterator;
    17
    18 // cspell:ignore dummydb
    19
    20 /**
    21 * DummyDB test implementation of \Drupal\Core\Database\Connection.
    22 */
    23 class Connection extends CoreConnection {
  • daffie added 3 commits

    added 3 commits

    • c9c39665 - 1 commit from branch project:11.x
    • a5a33754 - Merge branch '11.x' into 3450706-11-x-let-for-all
    • 10a41ac0 - Make the dummydb database driver dependent on the one for MySQL

    Compare with previous version

  • Please register or sign in to reply
    Loading