]> git.mjollnir.org Git - moodle.git/commitdiff
Only send contexts to cache if the aren't empty. At initial installations
authorstronk7 <stronk7>
Fri, 8 Sep 2006 19:28:03 +0000 (19:28 +0000)
committerstronk7 <stronk7>
Fri, 8 Sep 2006 19:28:03 +0000 (19:28 +0000)
some empty contexts were being cached and used later, causing insertion
of null values to every DB but MySQL.

lib/accesslib.php

index eac0d5adc20641478e93f59146dc114b740c24dd..ad307a9dfcb1840f3dafa34411c044248f974733 100755 (executable)
@@ -977,10 +977,11 @@ function get_context_instance($aggregatelevel=NULL, $instance=SITEID) {
         $context = get_record('context', 'aggregatelevel', $aggregatelevel, 'instanceid', $instance);
     }
 
-/// Update the cache
-    $context_cache[$aggregatelevel][$instance] = $context;    // Cache it for later
-    $context_cache_id[$context->id] = $context;      // Cache it for later
-
+/// Only add to cache if context isn't empty.
+    if (!empty($context)) {
+        $context_cache[$aggregatelevel][$instance] = $context;    // Cache it for later
+        $context_cache_id[$context->id] = $context;      // Cache it for later
+    }
 
     return $context;
 }