mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
[PR #8356] fix(persistent-collection): check "association" is not nullable before using it as an array #10943
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original Pull Request: https://github.com/doctrine/orm/pull/8356
State: closed
Merged: No
Hi,
Today I've faced an issue with Doctrine 2.7 and https://github.com/KnpLabs/DoctrineBehaviors when configuring the parameter
doctrine_behaviors_translatable_fetch_modetoLAZY(see KnpDoctrineBehaviors Translatable configuration):By using xdebug, I found it was coming from the method

PersistentCollection#get()which try to use$this->associationwhen it is equal tonull:There are already some methods that check if
$this->association !== null:changed: https://github.com/doctrine/orm/blob/e0eb82a/lib/Doctrine/ORM/PersistentCollection.php#L294remove: https://github.com/doctrine/orm/blob/e0eb82a/lib/Doctrine/ORM/PersistentCollection.php#L357removeElement: https://github.com/doctrine/orm/blob/e0eb82a/lib/Doctrine/ORM/PersistentCollection.php#L380count: https://github.com/doctrine/orm/blob/e0eb82a/lib/Doctrine/ORM/PersistentCollection.php#L443So I've applied the same patch on all other methods that use
$this->associationwithout checking its value.WDYT? Thanks!