]> git.mjollnir.org Git - moodle.git/commitdiff
merged fix for MDL-9016, clear context cache after remove_course_contents()
authortoyomoyo <toyomoyo>
Fri, 23 Mar 2007 07:21:27 +0000 (07:21 +0000)
committertoyomoyo <toyomoyo>
Fri, 23 Mar 2007 07:21:27 +0000 (07:21 +0000)
lib/accesslib.php
lib/moodlelib.php

index 9f4c2eebe6c7850b1828916aae1e93d47005eb81..6a9648f4f7178a4490b7d468afb99422985a0402 100755 (executable)
@@ -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)) {
index d8cc0bf7f40fe410cc336fa401e1688a62bb8598..dced08052dc93e01271a0ff321d394be2f7a13b4 100644 (file)
@@ -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;
 }