Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
In 10.1.x my unit tests for entity_hierarchy work. In 10.2.x I get the following error.
This is because the database info for 'driver' as returned by Database::getAllConnectionInfo()
is now a class name.
1) Drupal\Tests\entity_hierarchy\Functional\DeleteParentWarningTest::testDeleteWarning
Doctrine\DBAL\Exception: The given 'driver' pdo_Drupal\mysql\Driver\Database\mysql is unknown, Doctrine currently supports only the following drivers: pdo_mysql, pdo_sqlite, pdo_pgsql, pdo_oci, oci8, ibm_db2, pdo_sqlsrv, mysqli, drizzle_pdo_mysql, sqlanywhere, sqlsrv
/var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:138
/var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php:296
/var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php:250
/var/www/html/modules/contrib/dbal/src/ConnectionFactory.php:78
/var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php:255
/var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php:177
/var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php:440
/var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php:237
/var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php:177
/var/www/html/modules/contrib/entity_hierarchy/tests/src/Traits/EntityHierarchyTestTrait.php:55
/var/www/html/modules/contrib/entity_hierarchy/tests/src/Functional/DeleteParentWarningTest.php:43
/var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php:728
Steps to reproduce
Get 10.2.x and use ConnectionFactory
to get a database connection.
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#8 | 3400406.patch | 1.22 KB | larowlan |
Comments
Comment #2
larowlanSo this isn't an issue on 10.1?
Comment #3
larowlanIf so I think we can use the new BC layer - https://www.drupal.org/node/3379306 if we make the code to derive the pdo class an anonymous function
Comment #4
larowlanHmm I'm seeing this in the connection factory
which seems to indicate they're still string
🤔
Comment #5
ansergeyg CreditAttribution: ansergeyg commentedI confirm we have the same issue in our unit tests. We use different db drivers in our project. And after upgrading to 10.2.1, test that use different dib drivers are no longer working in our project. Would be nice to give it a priority or provide a fix. In our case sparql driver doesn't work anymore.
Regards
Comment #6
larowlanIs this test specific?
I've seen it in tests but can't find the source of it
Comment #7
larowlanhttps://git.drupalcode.org/project/entity_hierarchy/-/jobs/630574 showing a failing test for entity_hierarchy with this issue
Comment #8
larowlanIts ugly, but something like this?
Comment #11
larowlanCommitted to 8.x-1.x and c/p to 2.x