From d1f010c7fa2c2f275a0019f619097308a00bb051 Mon Sep 17 00:00:00 2001 From: Colan Schwartz Date: Thu, 16 May 2013 17:58:01 -0400 Subject: [PATCH] Issue #1670848 by ndeschildre, colan: Only cache entities loaded by ID. --- entitycache.module | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/entitycache.module b/entitycache.module index bbc39b8..3a675cb 100644 --- a/entitycache.module +++ b/entitycache.module @@ -112,7 +112,15 @@ class EntityCacheControllerHelper extends DrupalDefaultEntityController { if (!empty($controller->entityInfo['entity cache'])) { // Add entities to the entity cache if we are not loading a revision. if (!empty($queried_entities) && !$revision_id) { - self::entityCacheSet($controller, $queried_entities); + // Only cache the entities which were loaded by ID. Entities that were + // loaded based on conditions will never be found via cacheGet() and we + // would keep on caching them. + if ($passed_ids) { + $queried_entities_by_id = array_intersect_key($queried_entities, $passed_ids); + if (empty($queried_entities_by_id) == FALSE) { + self::entityCacheSet($controller, $queried_entities_by_id); + } + } } } -- 1.7.10.4