From: stronk7 Date: Fri, 8 Sep 2006 19:28:03 +0000 (+0000) Subject: Only send contexts to cache if the aren't empty. At initial installations X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=ccfc5ecca17542e4e6bc0e577a35d07f34410f29;p=moodle.git Only send contexts to cache if the aren't empty. At initial installations some empty contexts were being cached and used later, causing insertion of null values to every DB but MySQL. --- diff --git a/lib/accesslib.php b/lib/accesslib.php index eac0d5adc2..ad307a9dfc 100755 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -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; }