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)) {
function glossary_filter($courseid, $text) {
global $CFG;
+ // Trivial-cache - keyed on $cachedcourseid
static $nothingtodo;
static $conceptlist;
-
- if (!empty($nothingtodo)) { // We've been here in this page already
- return $text;
- }
+ static $cachedcourseid;
if (empty($courseid)) {
$courseid = SITEID;
}
+ // Initialise/invalidate our trivial cache if dealing with a different course
+ if (!isset($cachedcourseid) || $cachedcourseid !== (int)$courseid) {
+ $conceptlist = array();
+ $nothingtodo = false;
+ }
+ $cachedcourseid = (int)$courseid;
+
+ if ($nothingtodo === true) {
+ return $text;
+ }
+
/// Create a list of all the concepts to search for. It may be cached already.
if (empty($conceptlist)) {
global $CFG;
+ // Trivial-cache - keyed on $cachedcourseid
static $nothingtodo;
static $resourcelist;
+ static $cachedcourseid;
- if (!empty($nothingtodo)) { // We've been here in this page already
+ // if we don't have a courseid, we can't run the query, so
+ if (empty($courseid)) {
return $text;
}
- // if we don't have a courseid, we can't run the query, so
- if (empty($courseid)) {
+ // Initialise/invalidate our trivial cache if dealing with a different course
+ if (!isset($cachedcourseid) || $cachedcourseid !== (int)$courseid) {
+ $resourcelist = array();
+ $nothingtodo = false;
+ }
+ $cachedcourseid = (int)$courseid;
+
+ if ($nothingtodo === true) {
return $text;
}
global $CFG;
+ // Trivial-cache - keyed on $cachedcourseid
static $nothingtodo;
static $wikipagelist;
-
- if (!empty($nothingtodo)) { // We've been here in this page already
- return $text;
- }
+ static $cachedcourseid;
if (empty($courseid)) {
$courseid = SITEID;
}
+ // Initialise/invalidate our trivial cache if dealing with a different course
+ if (!isset($cachedcourseid) || $cachedcourseid !== (int)$courseid) {
+ $wikipagelist = array();
+ $nothingtodo = false;
+ }
+ $cachedcourseid = (int)$courseid;
+
+ if (!empty($nothingtodo)) { // We've been here in this page already
+ return $text;
+ }
+
/// Create a list of all the wikis to search for. It may be cached already.
if (empty($wikipagelist)) {