mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
PersistentCollection::matching uses getters #6158
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?
Originally created by @arnaud-lb on GitHub (Jan 21, 2019).
Bug Report
Summary
PersistentCollection::matchingmay use getters to fetch field values. This enforces the implementation of getters for every property that may be referenced in a criteria, and forces the getters to return a scalar (it is not possible to return a value object, for example).This is troublesome for multiple reasons:
PersistentCollection::matchinguses different strategy that doesn't have access to getters. As a result, aCriteriawill have different behaviours depending on the state of the collection (loaded in memory or not). For example, if aCriteriareferences a field whose getter does not exist or returns a value object,matching()will not work as expected when the collection is loaded in memory.Current behaviour
PersistentCollection::matchingmay or may not use getters during execution, depending on the state of the collection.How to reproduce
In this code,
Board::openIssues()will find open issues when the$issuescollection is not initialised, and will silently fail to find open issues when the collection is initialised.Expected behaviour
PersistentCollection::matchingmust have predictable behaviour. Its behaviour should not depend on whether the collection is initialised or not.@Ocramius commented on GitHub (Jan 21, 2019):
Pretty much on board with this: the reliance on transparent getters is dangerous and un-productive.
The problem is that the ship already sailed here, so we can only change this behavior in a major version of the tools, and deprecate this behavior in
doctrine/collections.