-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Open
Description
Bug Report
| Q | A |
|---|---|
| Version | 2.20.x |
Summary
A test started to fail since a few days on the 2.20.x branch with PHP master and 8.5, but not if it is run standalone.
Current behavior
1) Doctrine\Tests\ORM\Functional\Ticket\SwitchContextWithFilterAndIndexedRelation\ChangeFiltersTest::testIndexAliasUpdatedWithUpdatedFilter
Using null as an array offset is deprecated, use an empty string instead
/.../OSS/orm/src/Mapping/ClassMetadataInfo.php:3302
/.../OSS/orm/src/UnitOfWork.php:3177
/.../OSS/orm/src/Internal/Hydration/SimpleObjectHydrator.php:181
/.../OSS/orm/src/Internal/Hydration/SimpleObjectHydrator.php:66
/.../OSS/orm/src/Internal/Hydration/AbstractHydrator.php:276
/.../OSS/orm/src/Persisters/Entity/BasicEntityPersister.php:787
/.../OSS/orm/src/EntityRepository.php:240
/.../OSS/orm/tests/Tests/ORM/Functional/Ticket/SwitchContextWithFilterAndIndexedRelation/ChangeFiltersTest.php:42
Expected behavior
No test failure
How to reproduce
/path/to/php-8.5 vendor/bin/phpunit tests/Tests/ORM/Functional/Ticket
Potential fix
I have no idea why $assoc['mappedBy'] ends up being null when the test is run after other tests. However the following diff fixes the test.
diff --git a/src/UnitOfWork.php b/src/UnitOfWork.php
index adae0cb38..d2b0e4545 100644
--- a/src/UnitOfWork.php
+++ b/src/UnitOfWork.php
@@ -3174,7 +3174,7 @@ EXCEPTION
if ($hints['fetchMode'][$class->name][$field] === ClassMetadata::FETCH_EAGER) {
$isIteration = isset($hints[Query::HINT_INTERNAL_ITERATION]) && $hints[Query::HINT_INTERNAL_ITERATION];
- $isForeignKeyComposite = $targetClass->hasAssociation($assoc['mappedBy']) && count($targetClass->getAssociationMapping($assoc['mappedBy'])['joinColumns'] ?? []) > 1;
+ $isForeignKeyComposite = $targetClass->hasAssociation($assoc['mappedBy'] ?? '') && count($targetClass->getAssociationMapping($assoc['mappedBy'])['joinColumns'] ?? []) > 1;
if ($assoc['type'] === ClassMetadata::ONE_TO_MANY && ! $isIteration && ! $isForeignKeyComposite && ! isset($assoc['indexBy'])) {
$this->scheduleCollectionForBatchLoading($pColl, $class);Metadata
Metadata
Assignees
Labels
No labels