VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: balai on July 13, 2017, 11:25:11 AM

Title: Bug in VmConfig::set
Post by: balai on July 13, 2017, 11:25:11 AM
I am checking your VmConfig::set function.
You are using that in views like : components/com_virtuemart/views/category/view.html.php
Though none of these seem to work.

You can try your own
VmConfig::set('myVar', 10);
echo VmConfig::get('myVar',5); //gives 5
Title: Re: Bug in VmConfig::set
Post by: Ghost on July 13, 2017, 14:14:30 PM
You have to be logged in as VM admin for some reason https://dev.virtuemart.net/projects/virtuemart/repository/entry/branches/com_virtuemart.3.0.12.4/administrator/components/com_virtuemart/helpers/config.php

static function set($key, $value){

if (empty(self::$_jpConfig->_params)) {
self::loadConfig();
}

if($admin = JFactory::getUser()->authorise('core.admin', 'com_virtuemart')){
if (!empty(self::$_jpConfig->_params)) {
self::$_jpConfig->_params[$key] = $value;
}
}

}
Title: Re: Bug in VmConfig::set
Post by: balai on July 14, 2017, 12:18:19 PM
It makes no sense to be logged in, because this is used by the server to generate the front end views.
Title: Re: Bug in VmConfig::set
Post by: Milbo on July 25, 2017, 08:27:36 AM
Only admins are allowed to change the config!
Title: Re: Bug in VmConfig::set
Post by: balai on July 28, 2017, 18:36:05 PM
Max check your category view. It is used there, i suppose for backwards compatibility.
Title: Re: Bug in VmConfig::set
Post by: Milbo on July 29, 2017, 10:14:59 AM
You are right. Nice trap.The function is useless this way. I just notice, we have this lines in that function for more than 3 years. But we never used it before. I just remove it. The function is indeed meant for dynamic changes of the config and when someone reached this level, he can manipulate the config anyway.