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.
This commit is contained in:
stronk7 2006-09-08 19:28:03 +00:00
parent a13d2157f4
commit ccfc5ecca1

View File

@ -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;
}