/** * Clears the cache used in course_modinfo::instance() * * Used in {@link get_fast_modinfo()} when called with argument $reset = true * and in {@link rebuild_course_cache()} * * @param null|int|stdClass $courseorid if specified removes only cached value for this course */ public static function clear_instance_cache($courseorid = null) { if (empty($courseorid)) { self::$instancecache = array(); self::$cacheaccessed = array(); return; } if (is_object($courseorid)) { $courseorid = $courseorid->id; } if (isset(self::$instancecache[$courseorid])) { // Unsetting static variable in PHP is peculiar, it removes the reference, // but data remain in memory. Prior to unsetting, the varable needs to be // set to empty to remove its remains from memory. self::$instancecache[$courseorid] = ''; unset(self::$instancecache[$courseorid]); unset(self::$cacheaccessed[$courseorid]); } }