From 5afb01e8993b18e832280711683d49f96e715641 Mon Sep 17 00:00:00 2001
From: samhemelryk <samhemelryk>
Date: Wed, 9 Sep 2009 07:36:02 +0000
Subject: [PATCH] navigation MDL-20242 Fixed bug whereby sections that no
 longer exist were shown

---
 lib/navigationlib.php | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/navigationlib.php b/lib/navigationlib.php
index 24ed7c7ec7..9f39423c3e 100644
--- a/lib/navigationlib.php
+++ b/lib/navigationlib.php
@@ -1318,6 +1318,13 @@ class global_navigation extends navigation_node {
         $viewhiddensections = $this->cache->canviewhiddensections;
 
         $selectedstructure = optional_param($activeparam,false,PARAM_INT);
+
+        // This is required to make sure that if people have reduced the number
+        // of sections after adding activities to sections that no longer exist
+        // we dont show them
+        // MDL-20242
+        $sections = array_slice($sections, 0, $course->numsections, true);
+
         foreach ($sections as $section) {
             if ((!$viewhiddensections && !$section->visible) || (!$this->showemptybranches && !array_key_exists($section->section, $modinfo->sections))) {
                 continue;
-- 
2.39.5