Skip to main content

SQL error when all searched words have a length equal or less than the Min value

More
2 weeks 6 days ago #100000142 by oxido
-- HikaShop version -- : 6.6.0
-- Joomla version -- : 5.4.8
-- PHP version -- : 8.3.33
-- Browser(s) name and version -- : Chrome 154.0

Hello,
I am encountering an SQL syntax error related to a custom product field used inside a HikaShop Filter. After detailed testing, I identified a specific pattern that seems to indicate a bug in how the Min/Max length filter generates its SQL conditions.
Code:
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')) AND ((hikam_vendor.vendor_published IS NULL OR hikam_vendor.vendor_publish...' at line 1
Context
  • "pas cu pas" = "step by step".
  • I created a custom product field in HikaShop.
  • This field is used in a Filter module with Minimum length and Maximum length.
  • Search processing is set to “every words”.
Pattern of the issue
The SQL error appears only when all searched words have a length equal to or less than the Min value.
Examples:
  • If Min = 3 and the search term is “pas cu pas”, the error occurs because all words (“pas”, “cu”, “pas”) have length ≤ 3.
  • If Min = 2 and the search term is “pa cu pas”, the error does not occur because “pas” has 3 characters, which is greater than Min.
  • In general, if at least one searched word is longer than Min, the SQL error does not appear.
So the issue seems to be triggered only when " Search processing  " = "every words / any word" and Minimum length ≤ Searched value , which likely results in a malformed or empty SQL condition.

You have the link to the testing website, it is using ajax in search, so you need to refresh the page to see the error if not showing.

PS. In this new version of the forum I don't see the option to add protected data here, I would have given you the username and password to check on the testing site. :D

Please Log in or Create an account to join the conversation.

More
2 weeks 6 days ago #100000145 by nicolas
Hi,

Thank you for the detailed analysis, it was right. When the Minimum length setting removes all the words of the search, the text filter still added an empty condition to the SQL query, hence the SQL error. The words exactly as long as the minimum length were also removed, while only shorter words should be skipped, which is why "PAS CU PAS" with a minimum of 3 failed.

We fixed it: now words as long as the minimum length are kept ("PAS" is searched with a minimum of 3), and when no word is left the filter is simply ignored with the "Text entered too short" message, as when the whole search is too short.

The fix will be included in the next version of HikaShop. You can also download the install package of the current version on our website and install it on yours in order to get the patch.
The following user(s) said Thank You: oxido

Please Log in or Create an account to join the conversation.

Time to create page: 0.156 seconds
Powered by Kunena Forum