Index: ../../../../../_drupal/drupal7-curr/sites/all/modules/entity/includes/entity.controller.inc
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- ../../../../../_drupal/drupal7-curr/sites/all/modules/entity/includes/entity.controller.inc	(revision )
+++ ../../../../../_drupal/drupal7-curr/sites/all/modules/entity/includes/entity.controller.inc	(revision )
@@ -867,9 +867,20 @@
     $this->cacheComplete = FALSE;
     if (isset($ids)) {
 
-      foreach (array_intersect_key($this->entityCache, array_flip($ids)) as $id => $entity) {
-        unset($this->entityCacheByName[$this->entityCache[$id]->{$this->nameKey}]);
-        unset($this->entityCache[$id]);
+      if ($this->nameKey == $this->idKey || is_numeric(reset($ids))) {
+        $cache = $this->entityCache;
+        $is_name = false;
+      } else {
+        $cache = $this->entityCacheByName;
+        $is_name = true;
+      }
+      foreach (array_intersect_key($cache, array_flip($ids)) as $id => $entity) {
+        if($is_name) {
+          unset( $this->entityCache[$cache[$id]->{$this->idKey}] );
+        } else {
+          unset( $this->entityCacheByName[$cache[$id]->{$this->nameKey}] );
+        }
+        unset($cache[$id]);
       }
     }
     else {
