diff --git a/entitycache.module b/entitycache.module
index bbc39b8..bd8b673 100644
--- a/entitycache.module
+++ b/entitycache.module
@@ -66,7 +66,7 @@ class EntityCacheControllerHelper extends DrupalDefaultEntityController {
     // were passed. The $ids array is reduced as items are loaded from cache,
     // and we need to know if it's empty for this reason to avoid querying the
     // database when all requested entities are loaded from cache.
-    $passed_ids = !empty($ids) ? array_flip($ids) : FALSE;
+    $passed_ids = !empty($ids) ? array_flip(array_filter($ids)) : FALSE;
     // Try to load entities from the static cache, if the entity type supports
     // static caching.
     if ($controller->cache && !$revision_id) {