From ccfc5ecca17542e4e6bc0e577a35d07f34410f29 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Fri, 8 Sep 2006 19:28:03 +0000 Subject: [PATCH] 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. --- lib/accesslib.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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; } -- 2.39.5