Hi everyone
using J3.3.6 and VM3.0.2 (i think the problem also was in 3.0.0)
I have some customplugins that i have rewritten using the guides found on this page and http://reinhold.kainhofer.com/software/tutorial-vm2-plugin-vm3.html
Currently im running into a problem where the customfield_params that are saved have | in them instead of being json_encoded.
This means when i try to "reload" the page, i get a lot of errors. particularly in this file
administrator/components/com_virtuemart/plugins/vmcustomplugin.php Line 100. Because the json_decode returns FALSE it cannot iterate over it. This should in my opinion be changed to if (is_array(...))
public function parseCustomParams (&$field, $xParams = 'customfield_params') {
VmTable::bindParameterable ($field, $xParams, $this->_varsToPushParam);
if (empty($field->custom_element)) {
return 0;
}
if (!empty($field->customfield_params) && is_string ($field->customfield_params)) {
$custom_params = json_decode ($field->customfield_params, TRUE);
line 100 foreach ($custom_params as $k => $v) {
if (!empty($v)) {
$field->$k = $v;
}
}
}
}
Cant find any place in my own extension code that should be changed to make use of json_decode
thx
Wel
Usually you should not care about that. VM should handle it for you.
So does that mean i can expect that its a bug that will be solved? The problem is that it "breaks" the data. This means i cannot edit the data through interface.
I don't think there are cases where parseCustomParams should be explicitly called in VM 3... That function is no longer called by the VM core, so you must apparently call it in your plugin...
In all my customfield plugins, I have:
if (!defined('VM_VERSION') or VM_VERSION < 3) { // Only needed in VM2
$this->parseCustomParams($field);
}
Do you have any reason to call that legacy function any more? If so, there is probably a better way to do it in VM3.
Best regards,
Reinhold
PS: While migrating my plugins, I remember I also ran into that very problem that the params are JSON-encoded strings concatenated by | and so parseCustomParams doesn't work any more. Unfortunately, I don't remember where this was and how exactly I solved this - maybe I resorted to using some method of the custom or customfields model... I just remember that I realized that parseCustomParams was not needed any more.