PHP 8.0 - Search function not working properly following upgrade to 1.5.8
Hello! We recently upgraded from Zen-Cart 1.5.6a to 1.5.8 and PHP 7.3.33 to 8.0. We are now having an issue with the search function.
It works fine when searching single words, but searching anything with a space gives a blank page with the error: “WARNING: An Error occurred, please let us know!”. The issue is the same for both the public-facing search and the admin search. In an admin search the error message is: "WARNING: An Error occurred, please let us know! If you were entering information, please press the BACK button in your browser and re-check the information you have entered to be sure you entered valid data." Searching multiple words does not result in an error message when we use quotes around the phrase, however it does not give any results for key words unless they are entered exactly as they appear in the product.
We are currently running MySQL 10.3.38-MariaDB-log.
We checked the error logs and see the following (example case searching the phrase “two words”, with some info redacted for privacy):
[11-Feb-2023 16:00:31 America/XXXXX] Request URI: /index.php?main_page=search_result&search_in_description=1&keyword=two+words, IP address: X.X.X.X, Language id 1
#1 trigger_error() called at [/home/XXXXX/public_html/includes/classes/db/mysql/query_factory.php:667]
#2 queryFactory->show_error() called at [/home/XXXXX/public_html/includes/classes/db/mysql/query_factory.php:634]
#3 queryFactory->set_error() called at [/home/XXXXX/public_html/includes/classes/db/mysql/query_factory.php:275]
#4 queryFactory->Execute() called at [/home/XXXXX/public_html/includes/classes/split_page_results.php:105]
#5 splitPageResults->__construct() called at [/home/XXXXX/public_html/includes/modules/pages/search_result/header_php.php:459]
#6 require(/home/XXXXX/public_html/includes/modules/pages/search_result/header_php.php) called at [/home/XXXXX/public_html/index.php:35]
--> PHP Fatal error: 1064: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 'OR pd.products_name LIKE '%words%' OR p.products_model LIKE '%words%' OR m...' at line 1 :: select count(distinct p.products_id) as total FROM (products p LEFT JOIN manufacturers m USING(manufacturers_id), products_description pd, categories c, products_to_categories p2c ) LEFT JOIN meta_tags_products_description mtpd ON (mtpd.products_id= p2c.products_id AND mtpd.language_id = 1) WHERE (p.products_status = 1 AND p.products_id = pd.products_id AND pd.language_id = 1 AND p.products_id = p2c.products_id AND p2c.categories_id = c.categories_id AND ( ( pd.products_name LIKE '%two%' OR p.products_model LIKE '%two%' OR m.manufacturers_name LIKE '%two%' OR mtpd.metatags_keywords LIKE '%two%' OR mtpd.metatags_description LIKE '%two%' OR pd.products_description LIKE '%two%') AND ( OR pd.products_name LIKE '%words%' OR p.products_model LIKE '%words%' OR m.manufacturers_name LIKE '%words%' OR mtpd.metatags_keywords LIKE '%words%' OR mtpd.metatags_description LIKE '%words%' OR pd.products_description LIKE '%words%') )) ==> (as called by) /home/XXXXX/public_html/includes/classes/split_page_results.php on line 105 <== in /home/XXXXX/public_html/includes/classes/db/mysql/query_factory.php on line 667.
We haven't modified any of the files that are mentioned in the error log. We're not sure where to look next at this stage... any help would be greatly appreciated!
Re: PHP 8.0 - Search function not working properly following upgrade to 1.5.8
getting the same in sites with up-to-the-minute 1.5.8
Re: PHP 8.0 - Search function not working properly following upgrade to 1.5.8
i am unclear if you did the upgrade correctly. i would replace these 2 files with these current live files:
https://github.com/zencart/zencart/b...ons_search.php
https://github.com/zencart/zencart/b...ge_results.php
you can click on the raw button towards the top or the copy icon a couple of icons over to get a copy of said file.
replace those 2 files, and let us know if that resolves the problem.
in your error log, the sql statement does have an extra `or` which is causing the problem. but on my version on v158, it does not include that extra or.
best.
Re: PHP 8.0 - Search function not working properly following upgrade to 1.5.8
We are using the functions_search.php from two weeks ago and split_page_results from four months ago on github.
Re: PHP 8.0 - Search function not working properly following upgrade to 1.5.8
Not seeing this when testing current contents of github (pre-1.5.8a).
Re: PHP 8.0 - Search function not working properly following upgrade to 1.5.8
Quote:
Originally Posted by
carlwhat
Replacing those 2 files resolved the issue and everything works perfectly now. Many thanks!
Re: PHP 8.0 - Search function not working properly following upgrade to 1.5.8
Search is not working properly in my fresh install of 1.5.8a. My installation specifics are at the end of this post.
I downloaded a new copy on Jan 21 and I have 2 fresh installs...one with no mods and the other with zca_bootstrap. These are my fallback troubleshooting installs to make sure any changes I make to my plug-in are not what is causing any issues I run into.
This search:
Code:
https://localhost/zencart-1.5.8a_unmodified/index.php?main_page=search_result&keyword=.+or+-&search_in_description=1&categories_id=&inc_subcat=1&manufacturers_id=&pfrom=100&pto=200&dfrom=&dto=
#1 - returns every single product in the catalog...regardless of price.
#2 - I had to put in a period or dash in the text box...leaving it blank is not allowed and putting a single space in makes it look like the search is empty. Being empty or allowing spaces should be allowed. If I want to do a price range search, I want it to return all products in that price range.
#3 - Same issue if you select a single manufacturer...text box can't be blank or have a single space. What if I want to see all of that manufacturers products? I know, there are other tools for doing that but those tools disappear on mobile devices or smaller screens now.
#4 - Same issue when selecting a category...
Where and how do I allow the text box to be empty or contain a space? I have mods on my 1.5.7d cart which are highly dependent on the search mechanism...those mods are useless in 1.5.8a unless I fix whatever is causing this behavior.
I will try the two files on github that are mentioned above. I just wanted the community to know that this is still an issue since I downloaded the 1.5.8a on Jan 21.
Thanks.
Server Host: localhost (127.0.0.1)
Database: zc158a_ezfeeds_jce_bootstrap
Store Home: C:/xampp/htdocs/zencart-1.5.8a_ezfeeds_jce_bootstrap/
Server OS: Windows NT DESKTOP-4B8U62U 10.0 build 19045 (Windows 10) AMD64
Server Date: 01/30/2024 10:24:55
Server Up Time: Unsupported
HTTP Server: Apache/2.4.54 (Win64) OpenSSL/1.1.1p PHP/8.0.23
PHP Version: 8.0.23 (Zend: 4.0.23)
PHP File Uploads: On
Upload Max Size: 512M
PHP Memory Limit: -1
POST Max Size: 1024M
Database Engine: MySQL 10.4.25-MariaDB
Database Host: localhost (127.0.0.1)
Database Date: 01/30/2024 10:24:55
Database Data Size: 831 kB
Database Index Size: 788 kB
MySQL Slow Query Log Status: Off
MySQL Slow Query Log File: DESKTOP-4B8U62U-slow.log
MySQL Mode: NO_ZERO_IN_DATE, NO_ZERO_DATE, NO_ENGINE_SUBSTITUTION
View the database configuration variables
Re: PHP 8.0 - Search function not working properly following upgrade to 1.5.8
I downloaded and installed the new files from github and they broke my install...white screen of death.
I saved the original files and will reinstall them.
I will dig in to see what is causing this...appreciate any and all help.
Re: PHP 8.0 - Search function not working properly following upgrade to 1.5.8
just as fyi, i can confirm that on v158a, the page:
index.php?main_page=search_result&keyword=.+or+-&search_in_description=1&categories_id=&inc_subcat=1&manufacturers_id=&pfrom=100 &pto=200&dfrom=&dto=
returns all products.
on the v200-alpha, the query returns all products from 100-200 and ones that are marked call for price.
Re: PHP 8.0 - Search function not working properly following upgrade to 1.5.8
Quote:
Originally Posted by
carlwhat
just as fyi, i can confirm that on v158a, the page:
index.php?main_page=search_result&keyword=.+or+-&search_in_description=1&categories_id=&inc_subcat=1&manufacturers_id=&pfrom=100 &pto=200&dfrom=&dto=
returns all products.
on the v200-alpha, the query returns all products from 100-200 and ones that are marked call for price.
Thanks for confirming.
I will download 2.0 and put relevant files in 1.5.8a to see if it corrects.
What are the relevant files?