News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Warning: Creating default object from empty value ... in helpers/cart.php

Started by Thomas Kuschel, May 22, 2012, 14:36:41 PM

Previous topic - Next topic

Thomas Kuschel

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)

//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:

//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

Milbo

I added this

if(empty($this->data)){
$this->data = new stdClass();
}
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Thomas Kuschel

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

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/