From: toyomoyo Date: Fri, 23 Mar 2007 07:21:27 +0000 (+0000) Subject: merged fix for MDL-9016, clear context cache after remove_course_contents() X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=9251b26fe822e9d61d399ec181f6a823d6b27382;p=moodle.git merged fix for MDL-9016, clear context cache after remove_course_contents() --- diff --git a/lib/accesslib.php b/lib/accesslib.php index 9f4c2eebe6..6a9648f4f7 100755 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -1792,6 +1792,15 @@ function get_context_instance($contextlevel=NULL, $instance=0) { static $allowed_contexts = array(CONTEXT_SYSTEM, CONTEXT_PERSONAL, CONTEXT_USER, CONTEXT_COURSECAT, CONTEXT_COURSE, CONTEXT_GROUP, CONTEXT_MODULE, CONTEXT_BLOCK); // Yu: Separating site and site course context - removed CONTEXT_COURSE override when SITEID + + // fix for MDL-9016 + if ($contextlevel == 'clearcache') { + // Clear ALL cache + $context_cache = array(); + $context_cache_id = array(); + $CONTEXT = ''; + return false; + } /// If no level is supplied then return the current global context if there is one if (empty($contextlevel)) { diff --git a/lib/moodlelib.php b/lib/moodlelib.php index d8cc0bf7f4..dced08052d 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -3076,7 +3076,12 @@ function remove_course_contents($courseid, $showfeedback=true) { if ($courseid != SITEID) { delete_context(CONTEXT_COURSE, $course->id); } - + + // fix for MDL-9016 + // clear the cache because the course context is deleted, and + // we don't want to write assignment, overrides and context_rel table + // with this old context id! + get_context_instance('clearcache'); return $result; }