Skip to content
Browse files

MDL-31631 navigation: Removed caching of activities and sections arra…

…ys in favour of relying on cminfo caching
  • Loading branch information...
1 parent 58db57a commit 7b88b81a49d8d8e5d2ea4bbb010bb268f4459001 Sam Hemelryk committed Mar 27, 2012
Showing with 36 additions and 41 deletions.
  1. +36 −41 lib/navigationlib.php
View
77 lib/navigationlib.php
@@ -1627,55 +1627,50 @@ protected function generate_sections_and_activities(stdClass $course) {
global $CFG;
require_once($CFG->dirroot.'/course/lib.php');
- if (!$this->cache->cached('course_sections_'.$course->id) || !$this->cache->cached('course_activites_'.$course->id)) {
- $modinfo = get_fast_modinfo($course);
- $sections = array_slice(get_all_sections($course->id), 0, $course->numsections+1, true);
+ $modinfo = get_fast_modinfo($course);
- $activities = array();
+ $sections = array_slice(get_all_sections($course->id), 0, $course->numsections+1, true);
+ $activities = array();
- foreach ($sections as $key => $section) {
- $sections[$key]->hasactivites = false;
- if (!array_key_exists($section->section, $modinfo->sections)) {
+ foreach ($sections as $key => $section) {
+ $sections[$key]->hasactivites = false;
+ if (!array_key_exists($section->section, $modinfo->sections)) {
+ continue;
+ }
+ foreach ($modinfo->sections[$section->section] as $cmid) {
+ $cm = $modinfo->cms[$cmid];
+ if (!$cm->uservisible) {
continue;
}
- foreach ($modinfo->sections[$section->section] as $cmid) {
- $cm = $modinfo->cms[$cmid];
- if (!$cm->uservisible) {
- continue;
- }
- $activity = new stdClass;
- $activity->section = $section->section;
- $activity->name = $cm->name;
- $activity->icon = $cm->icon;
- $activity->iconcomponent = $cm->iconcomponent;
- $activity->id = $cm->id;
- $activity->hidden = (!$cm->visible);
- $activity->modname = $cm->modname;
- $activity->nodetype = navigation_node::NODETYPE_LEAF;
- $activity->onclick = $cm->get_on_click();
- $url = $cm->get_url();
- if (!$url) {
- $activity->url = null;
- $activity->display = false;
- } else {
- $activity->url = $cm->get_url()->out();
- $activity->display = true;
- if (self::module_extends_navigation($cm->modname)) {
- $activity->nodetype = navigation_node::NODETYPE_BRANCH;
- }
- }
- $activities[$cmid] = $activity;
- if ($activity->display) {
- $sections[$key]->hasactivites = true;
+ $activity = new stdClass;
+ $activity->id = $cm->id;
+ $activity->course = $course->id;
+ $activity->section = $section->section;
+ $activity->name = $cm->name;
+ $activity->icon = $cm->icon;
+ $activity->iconcomponent = $cm->iconcomponent;
+ $activity->hidden = (!$cm->visible);
+ $activity->modname = $cm->modname;
+ $activity->nodetype = navigation_node::NODETYPE_LEAF;
+ $activity->onclick = $cm->get_on_click();
+ $url = $cm->get_url();
+ if (!$url) {
+ $activity->url = null;
+ $activity->display = false;
+ } else {
+ $activity->url = $cm->get_url()->out();
+ $activity->display = true;
+ if (self::module_extends_navigation($cm->modname)) {
+ $activity->nodetype = navigation_node::NODETYPE_BRANCH;
}
}
+ $activities[$cmid] = $activity;
+ if ($activity->display) {
+ $sections[$key]->hasactivites = true;
+ }
}
- $this->cache->set('course_sections_'.$course->id, $sections);
- $this->cache->set('course_activites_'.$course->id, $activities);
- } else {
- $sections = $this->cache->{'course_sections_'.$course->id};
- $activities = $this->cache->{'course_activites_'.$course->id};
}
+
return array($sections, $activities);
}

0 comments on commit 7b88b81

Please sign in to comment.
Something went wrong with that request. Please try again.