From: skodak Date: Sat, 23 May 2009 20:08:48 +0000 (+0000) Subject: MDL-19288 fixed limiting cached context - array_shift() was breaking array keys;... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=56f3599bb971b274f6ed4e724991eb41f28c082e;p=moodle.git MDL-19288 fixed limiting cached context - array_shift() was breaking array keys; merged from MOODLE_19_STABLE --- 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]); }