Skip to content
Snippets Groups Projects
Commit 85d1db75 authored by Demian Katz's avatar Demian Katz
Browse files

Fix to eliminate freestanding hyphens (these break some Solr queries).

parent 8537e48a
No related merge requests found
......@@ -1583,9 +1583,12 @@ class Solr implements ServiceLocatorAwareInterface,
'[', ']', '{', '}');
$input = preg_replace($patterns, $matches, $input);
// Freestanding hyphens can cause problems:
$lookahead = '(?=(?:[^\"]*+\"[^\"]*+\")*+[^\"]*+$)';
$input = preg_replace('/\s+-\s+' . $lookahead . '/', ' ', $input);
// Remove empty parentheses outside of quotation marks -- these will
// cause a fatal Solr error and should be ignored.
$lookahead = '(?=(?:[^\"]*+\"[^\"]*+\")*+[^\"]*+$)';
$parenRegex = '/\(\s*\)' . $lookahead . '/';
while (preg_match($parenRegex, $input)) {
$input = preg_replace($parenRegex, '', $input);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment