News:

Looking for documentation? Take a look on our wiki

Main Menu

Model UserFields BUG and suggested repair

Started by BELGOR, September 25, 2014, 19:13:35 PM

Previous topic - Next topic

BELGOR

Hello
i have found little wierd if statement in Userfields Model
/administrator/components/com_virtuemart/models/userfields.php
function getUserfield
line 187

please replace
if($name !==0){
$this->_data->load($id, $name);
}
$this->_data->load($id);

with
if($name !==0){
$this->_data->load($id, $name);
} else {
$this->_data->load($id);
}


In some cases i get instead of proper userfield object just empty default object, because it is overwrited with the secon load
Typically it happened when check for agreenment in cart.
There is in cart helper function to validate chekout
$agreed = $userFieldsModel->getUserfield('agreed','name');

if(empty($this->tosAccepted) and !empty($agreed->required) and $validUserDataBT!==-1){
$redirectMsg = null;// JText::_('COM_VIRTUEMART_CART_PLEASE_ACCEPT_TOS');
$this->tosAccepted = false;
vmInfo('COM_VIRTUEMART_CART_PLEASE_ACCEPT_TOS','COM_VIRTUEMART_CART_PLEASE_ACCEPT_TOS');
return $this->redirecter('index.php?option=com_virtuemart&view=cart' , $redirectMsg);
}

I do not get $agreed field because it is loaded right and right afteroverided with second bad load
Here are 2 SQL queries that resolves during that two loads
SELECT `#__virtuemart_userfields`.*  FROM `#__virtuemart_userfields`  WHERE `#__virtuemart_userfields`.`name` = "agreed"
SELECT `#__virtuemart_userfields`.*  FROM `#__virtuemart_userfields`  WHERE `#__virtuemart_userfields`.`virtuemart_userfield_id` = "agreed"

Milbo

Thank you.

The problems was already fixed in vm3, but I did not notice that we have it already in vm2. The fix is added and will be in the next version.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/