lat9 / gpsf

An update to the previous Numinix version, now supporting Zen Carts 1.5.6 and above (including 1.5.8a) as well as PHP versions 5.6 through 8.2.
GNU General Public License v2.0
2 stars 2 forks source link

PHP Deprecated: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated #39

Closed highburyeye closed 2 months ago

highburyeye commented 3 months ago

To prevent PHP Deprecated: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated on /public_html/includes/classes/gpsfFeedGenerator.php on line 852.

change

$attributes = []; foreach ($attributes_info as $next_att) { $variant_key = strtolower($next_att['products_options_name'] ?? '');//TC mod line 852 to prevent null being passed if ($this->isStringInArray($variant_key, $this->attributeVariants) === false) { continue; }

lat9 commented 3 months ago

Actually the prevention of an error with a misconfigured attribute comes in the SQL query above that line: https://github.com/lat9/gpsf/blob/f9ac7e05f5094ac6eba671e75c79702ce25c4940/includes/classes/gpsfFeedGenerator.php#L837-L848

Those joins should be INNER instead of LEFT, but that misuse of the join type did point out that your site has attributes for which no associated products_options record exists!

Noting that a similar issue will arise if the product's products_type isn't found in the product_types table or if the product has no records in the products_to_categories table.

highburyeye commented 3 months ago

Thanks - I will see if I can check my database. Would this mean products were deleted without deleting the attributes perhaps?

lat9 commented 3 months ago

Nope, it means that some of your products have attributes whose options_id or options_values_id references a non-existing products_options or products_options_values record, respectively.