// db version and use the rest from code.
if ($context) {
$c->cid = $context->cid;
- $c->status = $context->status;
+ // If status has been stored as overridden but user context no longer
+ // exists, we need to re-enable this system context.
+ if ($context->status == CONTEXT_OVERRIDDEN && !isset($ui[$c-namespace][$c->attribute][$c->value])) {
+ $c->status = CONTEXT_ENABLED;
+ }
+ // Otherwise, just use the stored status.
+ else {
+ $c->status = $context->status;
+ }
context_ui_save($c);
unset($system[$c->cid]); // remove this context from unused list
}