Description
Bug Report
When PersistentCollection::matching() is called, the result in terms of sorting depends on the collection being initialized or uninitialized.
Q | A |
---|---|
BC Break | no |
Version | 2.5 |
Summary
On an initialized collection, the "matching" is applied to the array content, which means sorting is basically untouched if the criteria does not provide additional sorting.
On an unitialized collection, the "matching" is queried through the database. Here the sorting of the collection isn't considered, only the sorting of the criteria is. More often than not, no predictable sorting is used here -- whenever the criteria comes without custom sorting.
Current behavior
PersistentCollection->matching(Criteria::create())
without sorting doesn't use the collections sorting either.
How to reproduce
- Used the Ecommerce category as a test case.
- Make Category::$children
@ORM/OrderBy({"name" = "ASC"})
- Fill unordered data
- As for
$category->getChildren()->matching(Criteria::create())
.
The result is not ordered according to the annotation.
Expected behavior
The result should be ordered according to the annotation.