From dbc29d28d2eeaa891e7fc11809330049091d43e4 Mon Sep 17 00:00:00 2001 From: Menno Holtkamp Date: Tue, 14 Apr 2015 09:47:57 +0200 Subject: [PATCH] Simplified way to fetch multiple entries when index does not matter --- .../ORM/Cache/Region/DefaultRegion.php | 29 ++++++------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php b/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php index 94a4f56ba..b210a8d8d 100644 --- a/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php +++ b/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php @@ -100,30 +100,19 @@ class DefaultRegion implements Region */ public function getMultiple(CollectionCacheEntry $collection) { - $keysToRetrieve = array(); + $result = array(); - foreach ($collection->identifiers as $index => $key) { - $keysToRetrieve[$index] = $this->name . '_' . $key->hash; - } - - $items = array_filter( - array_map([$this->cache, 'fetch'], $keysToRetrieve), - function ($retrieved) { - return false !== $retrieved; + foreach ($collection->identifiers as $key) { + $entry = $this->cache->fetch($this->name . '_' . $key->hash); + if ($entry === false) { + $result = null; + break; + } else { + $result[] = $entry; } - ); - - if (count($items) !== count($keysToRetrieve)) { - return null; } - $returnableItems = array(); - - foreach ($keysToRetrieve as $index => $key) { - $returnableItems[$index] = $items[$index]; - } - - return $returnableItems; + return $result; } /**