ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
I've encountered an issue when testing the github version on a new installation of Zen Cart 1.5.8
If i go to the admin page Catalog>Products with Attributes Stock (aka SBA)I get an SQL error warning.
Error log shows
The count query seems to be built usingCode:PHP Fatal error: 1060:Duplicate column name 'products_model' :: SELECT count(*) as totalttt FROM (SELECT DISTINCT pa.products_id, pd.products_name, p.products_quantity, p.products_model, p.products_image, p.products_type, p.master_categories_id, p.products_model FROM zen_products_attributes pa, zen_products_description pd, zen_products p WHERE pd.language_id=1 AND pa.products_id = pd.products_id AND pa.products_id = p.products_id ORDER BY p.products_model ) countresults ==> (as called by) /Users/dev/Sites/localhost/sbatest/SBAAdin/includes/classes/split_page_results.php on line 220 <== in /Users/dev/Sites/localhost/sbatest/includes/classes/db/mysql/query_factory.php on line 667.in admin/includes/classes/split_page_results.phpCode:private function numberRows(string $sql)
where the content of $sql is
and yet the sql query built in admin/includes/classes/products_with_attributes_stock.php at line 348 isCode:SELECT DISTINCT pa.products_id, pd.products_name, p.products_quantity, p.products_model, p.products_image, p.products_type, p.master_categories_id, p.products_model FROM zen_products_attributes pa, zen_products_description pd, zen_products p WHERE pd.language_id=1 AND pa.products_id = pd.products_id AND pa.products_id = p.products_id ORDER BY p.products_model
It seems that it is adding the order by content back into the main query.Code:$query_products = "SELECT DISTINCT pa.products_id, pd.products_name, p.products_quantity, p.products_model, p.products_image, p.products_type, p.master_categories_id, " . $search_order_by . " FROM " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p WHERE pd.language_id=" . (int)$language_id . " AND pa.products_id = pd.products_id AND pa.products_id = p.products_id " . $w . " ORDER BY " . $search_order_by . " " . $SearchRange;
It's not the first time I have seen this since beginning testing on 1.5.8 as I had an instance on the front end last week where adding p.products_model to a query (can't recall which one at the moment) resulted in the same error being logged on the store side. I discovered that it was writing the sort by fields to the query used for count.
This may be a bug in ZC core as I can't see any need to add additional fields other than what already existed in a query.
Peerhaps some form of check is required so that it doesn't lead to duplicate fields being used in the count query that gets built.
I have a fix for this. Doing some final testing as iwhen the same fix was applied against the possibility of remnant entries in the sba table might exist, the response was not as expected or desired. I'm trying to determine a test case to force the expected response.
The solution though to the above is not exactly what I would like to have to include, but it accomplished a few things. One it ensures that the query results include the field(s) necessary to support more stringent mysql server requirements, that the results are in the same sequence as they have been in the past (other than possibly having a duplicate of a necessary field, and it generally prevents creating a query that doesn't return any values, though it looks like someone would have to modify the code to create that condition.
I expect to have the solution to the identified issue along with a fix to a minor issue within a few hours as I have something else to address. In the mean time.
Thank you for identifying this issue that had not existed in previous Zen Cart versions.
ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
Several hours ago I pushed a commit to the master branch to address this issue. The operation of the split page code has been modified away from what has historically been suggested which now requires the associated query to be "right". Historically, the double up of result fields was not a problem; however, now it causes an issue to be raised. This may be why the other discussed query/page had an issue.
ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
I've noticed that the 1_5_6 admin directory has modifications to attributes_controller.php, invoice.php, orders.php and packing slip.php and yet the 1_5_7 and 1_5_8 directories only modify packing slip.php.
Are the modifications no longer required on 1.5.7 and 1.5.8, or were they inadvertently omitted from the relevant module directories?
ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
I'm getting the following error logged when trying to add to cart
Any suggestions?Code:[18-Jan-2023 00:10:40 Europe/Paris] PHP Fatal error: Uncaught Error: Cannot access protected property shoppingCart::$display_debug_messages in /Users/steph/Sites/localhost/tudorrose/includes/extra_cart_actions/stock_by_attributes.php:364 Stack trace: #0 /Users/steph/Sites/localhost/tudorrose/includes/main_cart_actions.php(30): include() #1 /Users/steph/Sites/localhost/tudorrose/includes/init_includes/init_cart_handler.php(42): require('/Users/steph/Si...') #2 /Users/steph/Sites/localhost/tudorrose/includes/autoload_func.php(40): require_once('/Users/steph/Si...') #3 /Users/steph/Sites/localhost/tudorrose/includes/application_top.php(237): require('/Users/steph/Si...') #4 /Users/steph/Sites/localhost/tudorrose/index.php(25): require('/Users/steph/Si...') #5 {main} thrown in /Users/steph/Sites/localhost/tudorrose/includes/extra_cart_actions/stock_by_attributes.php on line 364 [18-Jan-2023 00:10:40 Europe/Paris] Request URI: /index.php?main_page=product_info&cPath=1_2254_2255&products_id=12239&number_of_uploads=0&action=add_product, IP address: ::1 --> PHP Fatal error: Uncaught Error: Cannot access protected property shoppingCart::$display_debug_messages in /Users/steph/Sites/localhost/tudorrose/includes/extra_cart_actions/stock_by_attributes.php:364 Stack trace: #0 /Users/steph/Sites/localhost/tudorrose/includes/main_cart_actions.php(30): include() #1 /Users/steph/Sites/localhost/tudorrose/includes/init_includes/init_cart_handler.php(42): require('/Users/steph/Si...') #2 /Users/steph/Sites/localhost/tudorrose/includes/autoload_func.php(40): require_once('/Users/steph/Si...') #3 /Users/steph/Sites/localhost/tudorrose/includes/application_top.php(237): require('/Users/steph/Si...') #4 /Users/steph/Sites/localhost/tudorrose/index.php(25): require('/Users/steph/Si...') #5 {main} thrown in /Users/steph/Sites/localhost/tudorrose/includes/extra_cart_actions/stock_by_attributes.php on line 364.
ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
my apologies if you've already addressed this but it's so basic. After uploading files, the catalog still works but the admin is showing a 500 error. Now granted this server is driving me crazy and this might not be typical but there is no error log to track this. v1.5.8, php 8.1
The full-time Zen Cart Guru. WizTech4ZC.com
Bookmarks