MDL-19288 fixed limiting cached context - array_shift() was breaking array keys; merged from MOODLE_19_STABLE

This commit is contained in:
skodak 2009-05-23 20:08:48 +00:00
parent 074d3e8190
commit 56f3599bb9

View File

@ -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]);
}