MDL-63403 filter_glossary: only prepare_phrases_for_filtering once

This commit is contained in:
Tim Hunt
2018-10-18 18:41:30 +02:00
committed by Eloy Lafuente (stronk7)
parent 098d616a30
commit e208669c64
2 changed files with 13 additions and 7 deletions
+3 -1
View File
@@ -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]);
}
}
+10 -6
View File
@@ -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}.
*