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

Bug+Warning: Creating default object from empty value in cart.php on line 1304

Started by Thomas Kuschel, June 08, 2012, 10:51:20 AM

Previous topic - Next topic

Thomas Kuschel

Description:
PHP version 5.4.0,
VM: cart.php last svn and before, Jun 05 (https://dev.virtuemart.net/svn/virtuemart/trunk/virtuemart@6054 87cc427b-4a1e-0410-b729-b2260ec0f063)

I got a warning message if I add a product to the cart AND I'm not logged in (guest):
( ! ) Warning: Creating default object from empty value in /home/tkuschel/workspaces/cms/joomla/components/com_virtuemart/helpers/cart.php on line 1304
Remedy: - my proposal  8)
code: function prepareAddressRadioSelection(){

//Just in case
$this->user = VmModel::getModel('user');

$this->userDetails = $this->user->getUser();

// Shipment address(es)
if($this->user){
$_addressBT = $this->user->getUserAddressList($this->userDetails->JUser->get('id') , 'BT');

// Overwrite the address name for display purposes
if(empty($_addressBT)){
$_addressBT[0] = new StdClass();
}
$_addressBT[0]->address_type_name = JText::_('COM_VIRTUEMART_ACC_BILL_DEF');

$_addressST = $this->user->getUserAddressList($this->userDetails->JUser->get('id') , 'ST');

} else {
$_addressBT = array();
$_addressBT[0]->address_type_name = '<a href="index.php'
.'?option=com_virtuemart'
.'&view=user'
.'&task=editaddresscart'
.'&addrtype=BT'
. '">'.JText::_('COM_VIRTUEMART_ACC_BILL_DEF').'</a>'.'<br />';
$_addressST = array();
}
.......


Important note - Bug???:

* The else branch do only enter if the model "VirtueMartModelUser" does not exists. $this->user points to the instance of this model.
Former, I think the "if/else" should decide wheather there is a user or not?
So IMHO, at my site, the else branch is visited at no time!

Regards
Thomas Kuschel
http://www.loytec.com