VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: bcohen0 on August 28, 2017, 01:00:33 AM

Title: Problem in getProductCategories, Virtuemart 3.2.2
Post by: bcohen0 on August 28, 2017, 01:00:33 AM
Yes, I know I have to update, and I will, but I don't think it will affect this issue.

This is in administrator/components/com_virtuemart/models/product.php, in function getProductCategories.  There is a line which casts an object to array, and it is throwing some kind of exception or something. I can't get closer to it because my debugger goes haywire at the call, or an attempt to do the object cast.

The original line is
            $tmp = (array)$catTable->load($categoryId['virtuemart_category_id']);

The casting is throwing into neverland. I can't do an evaluate expression either. When I change the cast to get_object_vars, all is well.

            $tmp = get_object_vars($catTable->load($categoryId['virtuemart_category_id']));

I'm wondering, if tmp doesn't need the private parts or methods of the table, perhaps using get_object_vars is better/safer?
I've looked at the uncast object returned by the load and I don't see anything obviously wrong with it, with my inexperienced eye.



Title: Re: Problem in getProductCategories, Virtuemart 3.2.2
Post by: Milbo on August 28, 2017, 09:08:32 AM
You use php7, right? It would explain, why it is suddenly a problem.
Title: Re: Problem in getProductCategories, Virtuemart 3.2.2
Post by: bcohen0 on August 28, 2017, 23:27:40 PM
Oh! No, I don't, I'm working on my client's system, and he doesn't.  Thanks for the info. I'll try it out.
Title: Re: Problem in getProductCategories, Virtuemart 3.2.2
Post by: Milbo on August 29, 2017, 08:19:03 AM
Quote from: bcohen0 on August 28, 2017, 01:00:33 AM
The original line is
            $tmp = (array)$catTable->load($categoryId['virtuemart_category_id']);

The original line is now $tmp = $catTable->load($categoryId['virtuemart_category_id'])->loadFieldValues(); and the loadFieldValues does the array
Title: Re: Problem in getProductCategories, Virtuemart 3.2.2
Post by: bcohen0 on September 02, 2017, 05:11:42 AM
Thank you! I have updated, I see this change now.