From c48f58ba9f127647c09325a9fcad558915a3a08d Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Wed, 13 Nov 2013 11:02:35 +0000 Subject: [PATCH] MDL-42863 make capabilities overview more fault-tolerant. --- admin/tool/capability/index.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/admin/tool/capability/index.php b/admin/tool/capability/index.php index 3f9c58edd0c..0bc2c3d4b61 100644 --- a/admin/tool/capability/index.php +++ b/admin/tool/capability/index.php @@ -139,9 +139,15 @@ if ($capability) { // Put the contexts into a tree structure. foreach ($contexts as $conid => $con) { $context = context::instance_by_id($conid); - $parentcontextid = get_parent_contextid($context); - if ($parentcontextid) { - $contexts[$parentcontextid]->children[] = $conid; + try { + $parentcontext = $context->get_parent_context(); + if ($parentcontext) { // Will be false if $context is the system context. + $contexts[$parentcontext->id]->children[] = $conid; + } + } catch (dml_missing_record_exception $e) { + // Ignore corrupt context tree structure here. Don't let it break + // showing the rest of the report. + continue; } }