From 56f3599bb971b274f6ed4e724991eb41f28c082e Mon Sep 17 00:00:00 2001 From: skodak Date: Sat, 23 May 2009 20:08:48 +0000 Subject: [PATCH] MDL-19288 fixed limiting cached context - array_shift() was breaking array keys; merged from MOODLE_19_STABLE --- lib/accesslib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/accesslib.php b/lib/accesslib.php index 8b186a7330..8e17ba8ef9 100755 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -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]); } -- 2.39.5