If I search for brown, and have documents that contain brown and Brown. I only get brown highlighted and not all occurences.

CommentFileSizeAuthor
#11 highlight.module.patch957 bytesguardian
#5 highlight.patch963 bytesstevenpatz

Comments

stevenpatz’s picture

Status: Active » Needs review
mindless’s picture

Title: Highlight is not working properly. » Highlight is case sensitive even when search isn't
Status: Needs review » Active

don't see a patch. updated title.

stevenpatz’s picture

Turns out the fix for this, that I wanted to use is a PHP5 only solution.

mindless’s picture

Havn't seen any activity here.. maybe it is worth posting the PHP5 solution, at least as a starting point.

stevenpatz’s picture

Version: 4.6.x-1.x-dev » master
Assigned: Unassigned » stevenpatz
Priority: Critical » Normal
Status: Active » Needs review
StatusFileSize
new963 bytes

Currently the highlight module uses:
str_replace

And it should use:
str_ireplace

Which according to this:

http://us2.php.net/manual/en/function.str-ireplace.php

Is for PHP 5 only.

stevenpatz’s picture

Priority: Normal » Critical
stevenpatz’s picture

Priority: Critical » Normal
nedjo’s picture

Status: Needs review » Needs work

Good idea, but because it's PHP 5 we'd need a PHP 4 workaround.

stevenpatz’s picture

Assigned: stevenpatz » Unassigned
pjb’s picture

Hi,

In the comments for the str_ireplace() function someone submitted what looks to be a PHP4-compatible solution:

if(!function_exists('str_ireplace')) {
   function str_ireplace($search, $replacement, $string){
       $delimiters = array(1,2,3,4,5,6,7,8,14,15,16,17,18,19,20,21,22,23,24,25,
       26,27,28,29,30,31,33,247,215,191,190,189,188,187,186,
       185,184,183,182,180,177,176,175,174,173,172,171,169,
       168,167,166,165,164,163,162,161,157,155,153,152,151,
       150,149,148,147,146,145,144,143,141,139,137,136,135,
       134,133,132,130,129,128,127,126,125,124,123,96,95,94,
       63,62,61,60,59,58,47,46,45,44,38,37,36,35,34);
       foreach ($delimiters as $d) {
           if (strpos($string, chr($d))===false){
               $delimiter = chr($d);
               break;
           }
       }
       if (!empty($delimiter)) {
           return preg_replace($delimiter.quotemeta($search).$delimiter.'i', $replacement, $string);
       }
       else {  
           trigger_error('Homemade str_ireplace could not find a proper delimiter.', E_USER_ERROR);
       }
   }
}

That might be a workaround, though the foreach() kind of worries me from a performance standpoint. Another comment mentions that this function is also part of the PHP_compat PEAR package, but I don't know how viable a solution that is for everyone.

guardian’s picture

StatusFileSize
new957 bytes

i quickly hacked a patch that uses preg_replace instead of string replace. I was not satistifed with the previous patches because using ?highlight=foo would effectively match "Foo" or any other case variation but the highlighted text would be "foo", that is would use the case from the search query or the URL query.

guardian’s picture

Status: Needs work » Reviewed & tested by the community

please if you applied the patch i submitted, could you report whether or not it works for you ?

arthurf’s picture

I just applied the patch. If you are interested in becoming a maintainer of this module I'd be glad to hand it over- my other work does quite give me the attention for this.

guardian’s picture

deal :)

arthurf’s picture

Guardian- I gave you CVS access. Once you've got everything under control, you can take full ownership. Thanks so much for taking this on!

memoday’s picture

Issue summary: View changes

Hello everybody, I am sorry to reopen this. How can you make this work for the D7 version? I checked the highlight.module and it's totally different from the batches here. Any idea?

memoday’s picture

never mind, you can actually achieve the same results by adding the i to the regex under admin/config/search/highlight/settings

for example: /.+[&?i]search_fulltext=([^&]+).*$

shenzhuxi’s picture

Version: master » 7.x-1.x-dev
Category: Bug report » Support request
Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.