]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-19288 fixed limiting cached context - array_shift() was breaking array keys;...
authorskodak <skodak>
Sat, 23 May 2009 20:08:48 +0000 (20:08 +0000)
committerskodak <skodak>
Sat, 23 May 2009 20:08:48 +0000 (20:08 +0000)
lib/accesslib.php

index 8b186a73307f3812a21a9155d5c4d02a8cebd554..8e17ba8ef91e0cac0573b272c82514d3f3e5ecb2 100755 (executable)
@@ -235,7 +235,8 @@ function cache_context($context) {
     // If there are too many items in the cache already, remove items until
     // there is space
     while (count($ACCESSLIB_PRIVATE->contextsbyid) >= MAX_CONTEXT_CACHE_SIZE) {
-        $first = array_shift($ACCESSLIB_PRIVATE->contextsbyid);
+        $first = reset($ACCESSLIB_PRIVATE->contextsbyid);
+        unset($ACCESSLIB_PRIVATE->contextsbyid[$first->id]);
         unset($ACCESSLIB_PRIVATE->contexts[$first->contextlevel][$first->instanceid]);
     }