Auto-linking filters: fix serious caching bug in forum mailouts

Autolinking of glossaries, activity, resources and wiki names were using a
trivial single-entry cache implemented with static vars. The cache was _not_
keyed on course.

This bug was visible during forum_cron() which walks many courses. The cache
would get "stuck" on the first course that had something to put in the cache.
All mailouts from there onwards would autolink to stuff in the wrong course.
This commit is contained in:
martinlanghoff 2007-03-19 06:33:45 +00:00
parent 8cf990bcfe
commit 9aa9080756
4 changed files with 47 additions and 12 deletions

View file

@ -8,12 +8,20 @@
global $CFG;
// Trivial-cache - keyed on $cachedcourseid
static $activitylist;
static $cachedcourse;
if (empty($courseid)) {
$courseid = SITEID;
}
// Initialise/invalidate our trivial cache if dealing with a different course
if (!isset($cachedcourseid) || $cachedcourseid !== (int)$courseid) {
$activitylist = array();
}
$cachedcourseid = (int)$courseid;
/// It may be cached
if (empty($activitylist)) {