Commit b98cd650 authored by Bernhard Schussek's avatar Bernhard Schussek
Browse files

Maintain order of IDs passed to getMultiple()

parent 76cbadcd
......@@ -137,14 +137,19 @@ abstract class ORMRepository extends EntityRepository implements EditableReposit
return new EmptyCursor();
$idStrings = array_map('strval', array_values($ids));
// Index by ID for the ID check below
$aggregates = $this->createQueryBuilder('e', sprintf('e.%s', $this->idField))
->where(sprintf('e.%s IN (:ids)', $this->idField))
->setParameter('ids', array_map('strval', array_values($ids)))
->setParameter('ids', $idStrings)
$cursor = new ArrayCursor($aggregates);
// Maintain the order of IDs
$sortedAggregates = array_replace(array_flip($idStrings), $aggregates);
$cursor = new ArrayCursor($sortedAggregates);
if ($ignoreMissing) {
return $cursor;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment