Forums / Bug Reports / [Not a core ZC bug] Search returning invalid keyword error

[Not a core ZC bug] Search returning invalid keyword error

Locked

Views: 1,349

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
18 Nov 2009, 9:17 PM
#1
grantgee avatar

grantgee

New Zenner

Join Date:
Jul 2007
Location:
Victor Harbor, SA
Posts:
11
Plugin Contributions:
0

[Not a core ZC bug] Search returning invalid keyword error

Zen 1.38a running on php 5.2.9 and MySql 5.081 Community

The search in the store continually returned "Invalid keyword" messages no matter what the input.
I searched but could find no reference.

After a day and a half of frustration and eventually with the help of the Debug Error Logging Utility - thank you, DrByte - I found the following error every time the search was run:
[18-Nov-2009 20:42:34] PHP Warning: preg_split() [<a href='function.preg-split'>function.preg-split</a>]: Unknown modifier '+'
in /home/<mysite>/public_html/includes/functions/functions_general.php on line 235

This is the code there:
$pieces = preg_split('[[:space:]]+', $search_str);

Did some research and finally added '/' delimiters around the left square bracket and the plus sign and the error went away and the search functioned as it should.:smile:

The code now looks like this:
$pieces = preg_split('/[[:space:]]+/', $search_str);

The file was the stock standard 1.38a one so I'm guessing it's some setting in php or something, causing this.

Hope this might be of some help to someone.

grantgee.

18 Nov 2009, 10:18 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: [Not a core ZC bug] Search returning invalid keyword error

Actually, someone has edited your original file.

v1.3.8a contains the following: ```
$pieces = split('[[:space:]]+', $search_str);


I wonder if you've got some addon installed that has altered the file.

I know PHP 5.3 deprecates the use of split() in favor of preg_split, but as you've seen, doing that requires the addition of delimiters in the call, as you posted.

The official PHP 5.3 patch for Zen Cart v1.3.8 already includes the appropriate delimiters.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

19 Nov 2009, 6:48 AM
#3
grantgee avatar

grantgee

New Zenner

Join Date:
Jul 2007
Location:
Victor Harbor, SA
Posts:
11
Plugin Contributions:
0

Re: [Not a core ZC bug] Search returning invalid keyword error

DrByte:

Actually, someone has edited your original file.
Yes, you are right, DrByte.
I was mistaken and the original file does indeed use "Split".
No wonder no-one else had the problem!
Not sure how it happened because none of the addons touched it but I do remembering replacing some splits for a Drupal problem on php 5.3 and I may have nuked all the splits in the wrong folder!
Oh well, all else seems okay - running like a clock.
Thanks,
grantgee