diff --git a/rules.module b/rules.module
index b99ce96..e76640c 100644
--- a/rules.module
+++ b/rules.module
@@ -244,10 +244,14 @@ function &rules_get_cache($cid = 'data') {
       rules_get_cache('data');
       return rules_get_cache($cid);
     }
-    elseif (!isset($cache['data'])) {
+    elseif (!isset($cache['data']) || (isset($cache['data']) && $cid != 'data')) {
       // There is no 'data' cache so we need to rebuild it. Make sure subsequent
       // cache gets of the main 'data' cache during rebuild get the interim
       // cache by passing in the reference of the static cache variable.
+      // 
+      // This second check is for the case when, for some reason, the data
+      // cache exists, but the cid is missing from the cache table. In that
+      // case, just try to rebuild the cache again.
       _rules_rebuild_cache($cache['data']);
     }
     else {
