diff --git a/entitycache.module b/entitycache.module
index bbc39b8..0fee316 100644
--- a/entitycache.module
+++ b/entitycache.module
@@ -66,6 +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.
+    $ids = array_filter($ids);
     $passed_ids = !empty($ids) ? array_flip($ids) : FALSE;
     // Try to load entities from the static cache, if the entity type supports
     // static caching.
