-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
JForm object loaded without data when first called with load_data option false #17700
Description
Steps to reproduce the issue
In the model of a component singular item, is a function called getForm which calls the parent function loadForm with the options to create a JForm object. The function getForm has a param loadData which defaults to true. When this function is first called with loadData set to false, and then called with loadData set to true, the JForm is returned without any data. There's a change whitch removes the setting for loading data when creating a signature, and then returns any previously loaded forms. The new code has this comment in file libraries/legacy/model/form.php ln 203:
// Create a signature hash. But make sure, that loading the data does not create a new instance
$sigoptions = $options;
I get the fact that we can use the previously created JForm, but now the entire loading of the data section is omitted, thus returning an JForm object without data.
Expected result
When setting the loadData to true, the data is actually loaded, regardless if the Form was created before.
Actual result
Empty JForm object, that is the JForm object is created correctly but with no data binded, even though the option specifies it should load it.
System information (as much as possible)
Joomla 3.7.4.
Additional comments
This problem is since Joomla 3.7.4, in 3.7.3 is was working fine. The problem lies in the fact that the signature is created regardless of the load data setting, which is fine, we don't need to create a new instance if the only difference is loading data, but the option should be handled when it is set to load.
Here is the code that generates the new hash, and if it exists, returns the object straight away, without rechecking if the data should be loaded. Of course there is the clear switch, but always setting this to true to make the data get loaded, is still not utilizing the previously created object.
$sigoptions = $options;
if (isset($sigoptions['load_data']))
{
unset($sigoptions['load_data']);
}
$hash = md5($source . serialize($sigoptions));
// Check if we can use a previously loaded form.
if (isset($this->_forms[$hash]) && !$clear)
{
return $this->_forms[$hash];
}
Metadata
Metadata
Assignees
Labels
Type
Projects
Status