diff --git a/filter/glossary/filter.php b/filter/glossary/filter.php index a3655708ea5..2c55c8a0e2a 100644 --- a/filter/glossary/filter.php +++ b/filter/glossary/filter.php @@ -135,6 +135,8 @@ class filter_glossary extends moodle_text_filter { // when you have two terms like 'Moodle' and 'Moodle 3.5'. You want the longest match. usort($conceptlist, 'filter_glossary::sort_entries_by_length'); + $conceptlist = filter_prepare_phrases_for_filtering($conceptlist); + $tocache = new stdClass(); $tocache->cacheuserid = $USER->id; $tocache->cachecourseid = $courseid; @@ -155,7 +157,7 @@ class filter_glossary extends moodle_text_filter { if (!empty($GLOSSARY_EXCLUDEENTRY)) { foreach ($conceptlist as $key => $filterobj) { - if ($filterobj->conceptid == $GLOSSARY_EXCLUDEENTRY) { + if (is_object($filterobj) && $filterobj->conceptid == $GLOSSARY_EXCLUDEENTRY) { unset($conceptlist[$key]); } } diff --git a/lib/filterlib.php b/lib/filterlib.php index ec4bd17a951..9b991c97c2e 100644 --- a/lib/filterlib.php +++ b/lib/filterlib.php @@ -1261,7 +1261,9 @@ function filter_phrases($text, $linkarray, $ignoretagsopen = null, $ignoretagscl $ignoretags = array(); // To store all the enclosig tags to be completely ignored. $tags = array(); // To store all the simple tags to be ignored. - $linkarray = filter_prepare_phrases_for_filtering($linkarray); + if (!isset($linkarray['__preparedmarker'])) { + $linkarray = filter_prepare_phrases_for_filtering($linkarray); + } if (!$overridedefaultignore) { // A list of open/close tags that we should not replace within. @@ -1305,7 +1307,11 @@ function filter_phrases($text, $linkarray, $ignoretagsopen = null, $ignoretagscl } // Time to cycle through each phrase to be linked. - foreach ($linkarray as $linkobject) { + foreach ($linkarray as $key => $linkobject) { + if ($key === '__preparedmarker') { + continue; + } + if ($linkobject->workregexp === null) { continue; } @@ -1427,13 +1433,11 @@ function filter_prepare_phrases_for_filtering(array $linkarray) { } } + $linkarray['__preparedmarker'] = 1; + return $linkarray; } -function filter_prepare_phrases_for_replacement() { - -} - /** * Remove duplicate from a list of {@link filterobject}. *