Always default the module name setting for database driver to their driver name
4 open threads
Closes #3450706
Merge request reports
Activity
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() { changed this line in version 2 of the diff
added 522 commits
-
bc981274...2fddf325 - 520 commits from branch
project:11.x - d3816f01 - Merge branch '11.x' into 3450706-11-x-let-for-all
- 029e22ca - Changed the used database name to dummydb
-
bc981274...2fddf325 - 520 commits from branch
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.
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
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 { changed this line in version 6 of the diff
added 231 commits
-
1568f273...91de3017 - 230 commits from branch
project:11.x - 6556cd07 - Merge branch '11.x' into 3450706-11-x-let-for-all
-
1568f273...91de3017 - 230 commits from branch
added 1 commit
- e170137f - Updated the fix and the testing as requested
added 1 commit
- 46d819e0 - Added the right dummydb database driver and removed the wrong one.
added 1 commit
- 09e0971f - Updated the dummydb database driver for style guide violations
added 1 commit
- 57429a43 - Moved the cspell exception to the top of the file
added 1 commit
- 2d7e9206 - 2 added dummy classes for fixing the PHPStan errors
added 1 commit
- db8a65ee - Added the abstract methods to DummyDB Schema
added 1 commit
- 4ce11cd1 - Added the abstract methods to DummyDB Upsert
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 {
Please register or sign in to reply