{"action":"opened","issue":{"url":"https://api.github.com/repos/joomla/joomla-cms/issues/17700","repository_url":"https://api.github.com/repos/joomla/joomla-cms","labels_url":"https://api.github.com/repos/joomla/joomla-cms/issues/17700/labels{/name}","comments_url":"https://api.github.com/repos/joomla/joomla-cms/issues/17700/comments","events_url":"https://api.github.com/repos/joomla/joomla-cms/issues/17700/events","html_url":"https://github.com/joomla/joomla-cms/issues/17700","id":252609758,"number":17700,"title":"JForm object loaded without data when first called with load_data option false","user":{"login":"conflate-nl","id":11771529,"avatar_url":"https://avatars0.githubusercontent.com/u/11771529?v=4","gravatar_id":"","url":"https://api.github.com/users/conflate-nl","html_url":"https://github.com/conflate-nl","followers_url":"https://api.github.com/users/conflate-nl/followers","following_url":"https://api.github.com/users/conflate-nl/following{/other_user}","gists_url":"https://api.github.com/users/conflate-nl/gists{/gist_id}","starred_url":"https://api.github.com/users/conflate-nl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/conflate-nl/subscriptions","organizations_url":"https://api.github.com/users/conflate-nl/orgs","repos_url":"https://api.github.com/users/conflate-nl/repos","events_url":"https://api.github.com/users/conflate-nl/events{/privacy}","received_events_url":"https://api.github.com/users/conflate-nl/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-08-24T13:55:33Z","updated_at":"2017-08-24T13:55:33Z","closed_at":null,"body":"### Steps to reproduce the issue\r\nIn 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:\r\n// Create a signature hash. But make sure, that loading the data does not create a new instance\r\n$sigoptions = $options;\r\n\r\nI 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. \r\n\r\n\r\n### Expected result\r\nWhen setting the loadData to true, the data is actually loaded, regardless if the Form was created before.\r\n\r\n\r\n### Actual result\r\nEmpty JForm object, that is the JForm object is created correctly but with no data binded, even though the option specifies it should load it.\r\n\r\n\r\n### System information (as much as possible)\r\nJoomla 3.7.4.\r\n\r\n\r\n### Additional comments\r\nThis 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. \r\nHere 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.\r\n$sigoptions = $options;\r\n\r\nif (isset($sigoptions['load_data']))\r\n{\r\n\tunset($sigoptions['load_data']);\r\n}\r\n$hash = md5($source . serialize($sigoptions));\r\n\r\n// Check if we can use a previously loaded form.\r\nif (isset($this->_forms[$hash]) && !$clear)\r\n{\r\n\treturn $this->_forms[$hash];\r\n}\r\n"}}
{"actor":{"display_login":"conflate-nl"}}