lat9 / edit_orders

Edit Orders: Updates for continued operation on Zen Cart v1.5.8 and later
GNU General Public License v2.0
5 stars 9 forks source link

Adding product with TEXT attributes causes crash #188

Closed scottcwilson closed 3 years ago

scottcwilson commented 3 years ago

[03-Mar-2021 09:34:59 America/Chicago] Request URI: /admin/edit_orders.php?oID=118281&action=update_order, IP address: 73.73.54.46

1 trigger_error() called at [/home/client/public_html/_live/includes/classes/db/mysql/query_factory.php:171]

2 queryFactory->show_error() called at [/home/client/public_html/_live/includes/classes/db/mysql/query_factory.php:143]

3 queryFactory->set_error() called at [/home/client/public_html/_live/includes/classes/db/mysql/query_factory.php:270]

4 queryFactory->Execute() called at [/home/client/public_html/_live/admin/includes/functions/extra_functions/edit_orders_functions.php:807]

5 eo_get_product_attribute_weight() called at [/home/client/public_html/_live/admin/includes/functions/extra_functions/edit_orders_functions.php:789]

6 eo_get_new_product() called at [/home/client/public_html/_live/admin/edit_orders.php:430]

--> 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 'LIMIT 1' at line 6 :: SELECT products_attributes_weight, products_attributes_weight_prefix FROM zen_products_attributes WHERE products_id = 472 AND options_id = 228 AND options_values_id = LIMIT 1 ==> (as called by) /home/client/public_html/_live/admin/includes/functions/extra_functions/edit_orders_functions.php on line 807 <== in /home/client/public_html/_live/includes/classes/db/mysql/query_factory.php on line 171.

Crash occurs because $attr['value_id'] is not set for TEXT attributes. Suggested fix: In eo_get_product_attribute_weight at the top, do

    if (empty($option_value_id)) return 0;
lat9 commented 3 years ago

Corrected via proper initialization of the TEXT attribute's value_id, setting that value to 0.