Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-26990 fix undefined rebuild_course_cache() regression

  • Loading branch information...
commit 112d3b49624a40842155c934476045ab0a17041a 1 parent 92a387b
@skodak skodak authored
Showing with 52 additions and 50 deletions.
  1. +0 −50 course/lib.php
  2. +52 −0 lib/modinfolib.php
View
50 course/lib.php
@@ -1881,56 +1881,6 @@ function get_category_or_system_context($categoryid) {
}
/**
- * Rebuilds the cached list of course activities stored in the database
- * @param int $courseid - id of course to rebuild, empty means all
- * @param boolean $clearonly - only clear the modinfo fields, gets rebuild automatically on the fly
- */
-function rebuild_course_cache($courseid=0, $clearonly=false) {
- global $COURSE, $DB, $OUTPUT;
-
- // Destroy navigation caches
- navigation_cache::destroy_volatile_caches();
-
- if ($clearonly) {
- if (empty($courseid)) {
- $courseselect = array();
- } else {
- $courseselect = array('id'=>$courseid);
- }
- $DB->set_field('course', 'modinfo', null, $courseselect);
- // update cached global COURSE too ;-)
- if ($courseid == $COURSE->id or empty($courseid)) {
- $COURSE->modinfo = null;
- }
- // reset the fast modinfo cache
- $reset = 'reset';
- get_fast_modinfo($reset);
- return;
- }
-
- if ($courseid) {
- $select = array('id'=>$courseid);
- } else {
- $select = array();
- @set_time_limit(0); // this could take a while! MDL-10954
- }
-
- $rs = $DB->get_recordset("course", $select,'','id,fullname');
- foreach ($rs as $course) {
- $modinfo = serialize(get_array_of_activities($course->id));
- $DB->set_field("course", "modinfo", $modinfo, array("id"=>$course->id));
- // update cached global COURSE too ;-)
- if ($course->id == $COURSE->id) {
- $COURSE->modinfo = $modinfo;
- }
- }
- $rs->close();
- // reset the fast modinfo cache
- $reset = 'reset';
- get_fast_modinfo($reset);
-}
-
-/**
* Gets the child categories of a given courses category. Uses a static cache
* to make repeat calls efficient.
*
View
52 lib/modinfolib.php
@@ -1080,6 +1080,58 @@ function get_fast_modinfo(&$course, $userid=0) {
return $cache[$course->id];
}
+/**
+ * Rebuilds the cached list of course activities stored in the database
+ * @param int $courseid - id of course to rebuild, empty means all
+ * @param boolean $clearonly - only clear the modinfo fields, gets rebuild automatically on the fly
+ */
+function rebuild_course_cache($courseid=0, $clearonly=false) {
+ global $COURSE, $DB, $CFG;
+
+ // Destroy navigation caches
+ navigation_cache::destroy_volatile_caches();
+
+ if ($clearonly) {
+ if (empty($courseid)) {
+ $courseselect = array();
+ } else {
+ $courseselect = array('id'=>$courseid);
+ }
+ $DB->set_field('course', 'modinfo', null, $courseselect);
+ // update cached global COURSE too ;-)
+ if ($courseid == $COURSE->id or empty($courseid)) {
+ $COURSE->modinfo = null;
+ }
+ // reset the fast modinfo cache
+ $reset = 'reset';
+ get_fast_modinfo($reset);
+ return;
+ }
+
+ require_once("$CFG->dirroot/course/lib.php");
+
+ if ($courseid) {
+ $select = array('id'=>$courseid);
+ } else {
+ $select = array();
+ @set_time_limit(0); // this could take a while! MDL-10954
+ }
+
+ $rs = $DB->get_recordset("course", $select,'','id,fullname');
+ foreach ($rs as $course) {
+ $modinfo = serialize(get_array_of_activities($course->id));
+ $DB->set_field("course", "modinfo", $modinfo, array("id"=>$course->id));
+ // update cached global COURSE too ;-)
+ if ($course->id == $COURSE->id) {
+ $COURSE->modinfo = $modinfo;
+ }
+ }
+ $rs->close();
+ // reset the fast modinfo cache
+ $reset = 'reset';
+ get_fast_modinfo($reset);
+}
+
/**
* Class that is the return value for the _get_coursemodule_info module API function.

0 comments on commit 112d3b4

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