From 22bf788f6b7d51bcdfba0ec317e5e5bb112041e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mudr=C3=A1k?= Date: Tue, 27 Aug 2013 11:40:18 +0200 Subject: [PATCH] MDL-40191 MDLSITE-2455 Do not throw coding exception when the activity is not found Under certain conditions, coding exception is thrown when fetching items from the navigation bar. The patch prevents them. See more details in the tracker. --- lib/navigationlib.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/navigationlib.php b/lib/navigationlib.php index cd931071860..a4078c84c89 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -1201,12 +1201,14 @@ class global_navigation extends navigation_node { // Load the course sections into the page $this->load_course_sections($course, $coursenode, null, $cm); $activity = $coursenode->find($cm->id, navigation_node::TYPE_ACTIVITY); - // Finally load the cm specific navigaton information - $this->load_activity($cm, $course, $activity); - // Check if we have an active ndoe - if (!$activity->contains_active_node() && !$activity->search_for_active_node()) { - // And make the activity node active. - $activity->make_active(); + if (!empty($activity)) { + // Finally load the cm specific navigaton information + $this->load_activity($cm, $course, $activity); + // Check if we have an active ndoe + if (!$activity->contains_active_node() && !$activity->search_for_active_node()) { + // And make the activity node active. + $activity->make_active(); + } } break; case CONTEXT_USER :