VirtueMart Forum

VirtueMart 2 + 3 => Virtuemart Development and bug reports => Development & Testing => Topic started by: Thomas Kuschel on May 22, 2012, 14:36:41 pm

Title: Warning: Creating default object from empty value ... in helpers/cart.php
Post by: Thomas Kuschel on May 22, 2012, 14:36:41 pm
Greetings!
Description:
When calling the cart module, the function prepareAjaxData() within components/com_virtuemart/helpers/cart.php pops up a warning message, shown in error log too:
 [error] [client 127.0.0.1] PHP Warning:  Creating default object from empty value in /xxxx/joomla/components/com_virtuemart/helpers/cart.php on line 1403, referer: http://loytec.com/en/myloytec/products-documents
This behavior is found in components/com_virtuemart/helpers/cart.php line 1397 ff (latest commit, 6 days ago)

Code: [Select]
//of course, some may argue that the $this->data->products should be generated in the view.html.php, but
//
$this->data->products = array();
$this->data->totalProduct = 0;
$i=0;
My suggestion: adding the following line to create an empty object,
this makes sense:
Code: [Select]
//of course, some may argue that the $this->data->products should be generated in the view.html.php, but
//
$this->data = new stdClass();
$this->data->products = array();
$this->data->totalProduct = 0;
$i=0;
regards,
Thomas Kuschel
http://loytec.com
Title: Re: Warning: Creating default object from empty value ... in helpers/cart.php
Post by: Milbo on May 25, 2012, 15:25:42 pm
I added this
Code: [Select]
if(empty($this->data)){
$this->data = new stdClass();
}
Title: Re: Warning: Creating default object from empty value ... in helpers/cart.php
Post by: Thomas Kuschel on May 31, 2012, 16:53:13 pm
Hi Milbo,

in that case, it isn't really necessary to query the emptiness of $this->data .

It has nothing to do with robustness nor security. The class do _not_ exists.

All the best

Thomas
Title: Re: Warning: Creating default object from empty value ... in helpers/cart.php
Post by: Milbo on June 01, 2012, 18:50:07 pm
Imho it can be manipulated by plugins.