Skip to content

Commit

Permalink
MDL-58257 course: fix search containing a hyphen
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ak4t0sh committed Mar 16, 2017
1 parent 98c4094 commit ce43799
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/datalib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit ce43799

Please sign in to comment.