Open arnaud-lb opened 5 years ago
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
.
Bug Report
Summary
PersistentCollection::matching
may 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::matching
uses different strategy that doesn't have access to getters. As a result, aCriteria
will have different behaviours depending on the state of the collection (loaded in memory or not). For example, if aCriteria
references 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::matching
may 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$issues
collection is not initialised, and will silently fail to find open issues when the collection is initialised.Expected behaviour
PersistentCollection::matching
must have predictable behaviour. Its behaviour should not depend on whether the collection is initialised or not.