I got this warning every now and then, can't figure out what the exact conditions are.
I've rebuilt the index but that doesn't resolve the issue.
Core Search module enabled or disabled doesn't have any influence either.

CommentFileSizeAuthor
#3 unknown-modifier-1469172-3.patch796 bytesmgifford

Comments

JCB’s picture

I am getting the same error...
See below.

Type php
User Anonymous
Location http://www.sitename.co.za/fuzzysearch/results/voip%20OR%20phones?page=17
Referrer
Message preg_replace(): Unknown modifier ')' in /usr/www/users/bestdkutkr/sites/sitename.co.za/modules/fuzzysearch/fuzzysearch.module on line 1125.
Severity error

Not sure why this happens.

Here is the code located at this position

// Wrap the found words in a <strong> tag to highlight them.
      $newbody = preg_replace('/' . $boundary . '[^' . PREG_CLASS_SEARCH_EXCLUDE . PREG_CLASS_CJK . ']*' . '(' . implode('|', $clean_words) . ')' . '[^' . PREG_CLASS_SEARCH_EXCLUDE . PREG_CLASS_CJK . ']*' . $boundary . '/iu', '<strong>\0</strong>', $newbody);

Let me know what you think...

Luisvsm’s picture

Status: Active » Needs review

I found a fix.

For me it was being caused by parentheses not being escaped properly from the matched word list, then when the script goes and bolds words that were matched (line 1125) it falls over.

What I did to fix it was escape parentheses in the selected words before they're passed to the bolding function.

//$clean_words[$k] = $matches[0][0];                               //Old line (fuzzysearch.module line 1089)
$clean_words[$k] = preg_replace('/[)]/', '\)', $matches[0][0]);    //New line

I'm not sure if there are more special characters that have neglected to be escaped, or if the words with parentheses will still be bolded as we actually hide the main text content on our search page for shorter page so I can't test it.

You could add more characters into the regex preg replace if it's getting tripped up by more than just parentheses.

mgifford’s picture

Version: 6.x-1.5 » 7.x-1.x-dev
Issue summary: View changes
StatusFileSize
new796 bytes

So I was actually experiencing this in D6, but this fix still seems relevant in D7. Here's a patch against the git repo.