Closed proseLA closed 2 years ago
The underlying issue, I think, is/was that the product for which a URL is to be built is not present, resulting in a NULL
return from zen_get_products_category_id
. I've tried to reproduce the issue, but have been unable to. It looks like all other cases within /includes/classes/usu.php
that use that function cast its return to an int
, other than the call in the class' get_product_canonical
method.
Noting that, while the code fragment provided can induce the issue, I'd be more comfortable that a solution really works if I could find a way to force the error via a misconfigured Zen Cart product. I've tried simply referencing an invalid product (as indicated in the debug-log supplied in the Zen Cart posting that you identified), but with no luck.
Either way, I believe the source of the issue is that missing cast in get_product_canonical
, so that's the way I'm tending. Thanks for the investigation, it helped a lot!
OK, issue reproduced. Turns out the issue is caused by a product that has an entry in the products_description
table, but not in the products
(what a mess!).
Adding that additional cast identified above results in the product being "not found" (as expected).
https://github.com/lat9/usu/blob/457f840a3592aeb9fb7179d0ae2e409cb6e625d7/includes/classes/usu.php#L899-L904
this thread has exposed a bug: https://tinyurl.com/y2aty628
here is some sample code to illustrate:
results of said test are:
because the original is being passed back by reference, it needs to be cast back to an integer. or i'm sure there are other solutions as well...