MDL-58257 course: fix search containing a hyphen

In case a hyphen (-) was preceded and followed by spaces,
the pattern for the "not regex" was empty causing an empty response from the database.
This commit is contained in:
Arnaud Trouve
2017-03-16 18:43:15 +01:00
parent 98c4094eac
commit ce4379973f
+1 -1
View File
@@ -787,7 +787,7 @@ function get_courses_search($searchterms, $sort, $page, $recordsperpage, &$total
$searchcond[] = "$concat $REGEXP :ss$i";
$params['ss'.$i] = "(^|[^a-zA-Z0-9])$searchterm([^a-zA-Z0-9]|$)";
} else if (substr($searchterm,0,1) == "-") {
} else if ((substr($searchterm,0,1) == "-") && (core_text::strlen($searchterm) > 1)) {
$searchterm = trim($searchterm, '+-');
$searchterm = preg_quote($searchterm, '|');
$searchcond[] = "$concat $NOTREGEXP :ss$i";