Jump to content

Weird System Error Log Entry


Dirty Butter

Recommended Posts

My Search is not standard, but one that @bsmither worked our for me. But I've never seen this error message before. I can't find an entry for this time in our Users Online for bots and customers. It's the "Got error 'parentheses not balanced' from regexp " part that I am concerned about.

Any idea what happened to cause that message?

File: [catalogue.class.php] Line: [1901] "SELECT I.* FROM CubeCart_inventory AS I LEFT JOIN (SELECT product_id, MAX(price) as price, MAX(sale_price) as sale_price FROM CubeCart_pricing_group WHERE group_id = 0 GROUP BY product_id) as G ON G.product_id = I.product_id WHERE I.product_id IN (SELECT product_id FROM `CubeCart_category_index` as CI INNER JOIN CubeCart_category as C where CI.cat_id = C.cat_id AND C.status = 1) AND I.status = 1 AND ((I.name RLIKE '[[:<:]]puffalump[[:>:]]' AND I.name RLIKE '[[:<:]]cat[[:>:]]' AND I.name RLIKE '[[:<:]]for[[:>:]]' AND I.name RLIKE '[[:<:]]purchase[[:>:]]' AND I.name RLIKE '[[:<:]](not[[:>:]]' AND I.name RLIKE '[[:<:]]sold)[[:>:]]') OR (I.description RLIKE '[[:<:]]puffalump[[:>:]]' AND I.description RLIKE '[[:<:]]cat[[:>:]]' AND I.description RLIKE '[[:<:]]for[[:>:]]' AND I.description RLIKE '[[:<:]]purchase[[:>:]]' AND I.description RLIKE '[[:<:]](not[[:>:]]' AND I.description RLIKE '[[:<:]]sold)[[:>:]]') OR (I.product_code RLIKE '[[:<:]]puffalump[[:>:]]' AND I.product_code RLIKE '[[:<:]]cat[[:>:]]' AND I.product_code RLIKE '[[:<:]]for[[:>:]]' AND I.product_code RLIKE '[[:<:]]purchase[[:>:]]' AND I.product_code RLIKE '[[:<:]](not[[:>:]]' AND I.product_code RLIKE '[[:<:]]sold)[[:>:]]') OR (I.seo_meta_keywords RLIKE '[[:<:]]puffalump[[:>:]]' AND I.seo_meta_keywords RLIKE '[[:<:]]cat[[:>:]]' AND I.seo_meta_keywords RLIKE '[[:<:]]for[[:>:]]' AND I.seo_meta_keywords RLIKE '[[:<:]]purchase[[:>:]]' AND I.seo_meta_keywords RLIKE '[[:<:]](not[[:>:]]' AND I.seo_meta_keywords RLIKE '[[:<:]]sold)[[:>:]]')) " - Got error 'parentheses not balanced' from regexp

Link to comment
Share on other sites

I do not see anything wrong with the overall structure of the query.

I would therefore conclude the problem is within a regex pattern, which does use parentheses for 'grouping'.

So,

AND I.product_code RLIKE '[[:<:]](not[[:>:]]'
AND I.product_code RLIKE '[[:<:]]sold)[[:>:]]'

has parentheses which will cause problems.

This illustrates a need for the search terms to be "escaped" against regex control characters, or have those characters stripped out.

Link to comment
Share on other sites

13 minutes ago, bsmither said:

This illustrates a need for the search terms to be "escaped" against regex control characters, or have those characters stripped out.

So.... how do I do that? Would "escaping" solve the trailing space issue I have posted in another thread?

Link to comment
Share on other sites

I will have to study your 'trailing space' issue separately.

I have not tried the following, but these two lines will remove characters that would interfere with the RLIKE word boundary syntax. But that opens other considerations.

In catalogue.class.php, searchCatalogue() function, find:

if(strtolower($search_mode) == 'rlike') {
	$like_keyword = "RLIKE";
	$like_prefix = '[[:<:]]';
	$like_postfix = '[[:>:]].*';
} else {
	$like_keyword = "LIKE";
	$like_prefix = '%';
	$like_postfix = '%';
}
for ($i=0; $i<$noKeys; ++$i) { dbgClue('Working with this term from $searchArray: '.$searchArray[$i],array(),false);
  $ucSearchTerm = strtoupper($searchArray[$i]);
  if (($ucSearchTerm != 'AND') && ($ucSearchTerm != 'OR')) {

On a new blankline AFTER that, add:

if(strtolower($search_mode) == 'rlike'){$searchArray[$i] = str_replace(array('.','^','$','*','+','?','(',')','[','{','\\','|'),'',$searchArray[$i]);}
if(strtolower($search_mode) == 'like'){$searchArray[$i] = str_replace(array('_','%'),array('\_','\%'),$searchArray[$i]);}

So,

AND I.product_code RLIKE '[[:<:]](not[[:>:]]'
AND I.product_code RLIKE '[[:<:]]sold)[[:>:]]'

will now look like:

AND I.product_code RLIKE '[[:<:]]not[[:>:]]'
AND I.product_code RLIKE '[[:<:]]sold[[:>:]]'

Even if escaped, as in '[[:<:]]sold\)[[:>:]]', the database engine would still ignore the escaped closing parenthesis because it is not an alphanumeric character.

In an RLIKE search term such as St.Louis, (no space) the period will be stripped, resulting in the term being StLouis.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...