-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#33834] Fixed JForm::bind for nested JObject argument #3737
Conversation
You can use git squash to make a single commit from these 6 commits. More about it is at http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html For current case |
JForm::bind method was relying on getProperties() which returned only the attributes of the given object. However in case one of these attributes happens to be a JObject instance itself, then JForm::bindLevel would fail there. In particular model's getItem function tends to return a nested JObject always. JArrayHelper call would take care of JObject to Array conversion recursively.
Thanks for the tip. 👍 |
Hello @izharaazmi Thank you for your contribution. The last comment here was on 8th June 2014. So the question is, is this issue/pull request still valid? Thanks for understanding! This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/3737. |
I dropped this idea as the JObject got deprecated. However the issue is Should I update the PR, or just close it?
|
Yes, it should be updated. Even though something is deprecated, it should continue to function correctly until it is removed. |
@izharaazmi If you can provide the test instructions soon that would be appreciated, I have a group of people testing issues tomorrow and I would be able to include this one. Thanks. |
To reproduce this we'd need the recursive For quick test do the following: Create a form XML with a field with xpath something like Motive is to make the field deep nested. Pass the JForm::bind a recursive JObject created from following object:
Binding level1 would be fine, but level2 will cause error as the protected property This holds true for all subsequent levels. My PR fixes this JObject to array conversion by using ArrayHelper instead of using Sample code for test:
|
Tested it but I couldn't see any differences between the changes. This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/3737. |
Make sure you have set I just verified and it shows the following warnings without this patch. After this patch the warnings are gone.
The warning occurs at following line:
|
Tested with Joomla version: 3.4.4-dev development
Test was successful! |
Just tested this successful with the sample code by @izharaazmi. Based on the test by @kathastaden I'm RTC'ing here. Thanks! This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/3737. |
[#33834] Fixed JForm::bind for nested JObject argument
Hi, Thank you for all of the work on Joomla 3.5 so far! I've just tested our code on Joomla 3.5 Beta and something didn't work well, then I did a back tracking and found the root cause is the change in this pull request. In our case, our Model return $item which has the following structure: $item (JObject) This structure has been worked fine since Joomla 3.0.0 and stopped this morning because JForm will automatically convert all nested objects to array silently. We can make a work around this but I am afraid of how many extensions out there are relying on the old JForm behavior. |
Currently it converts all nested objects to array silently (see joomla#3737). Some components relying on old behavior (prior to joomla#3737) may expect object values for the form fields. This fix does not process the entire nested structure, instead converts only binding levels to array for internal iterations.
Hi @izharaazmi, can you please do a PR against staging with your commit (izharaazmi@64bc802)? Thanks! |
@Kubik-Rubik It's on the way! |
JForm::bind method was relying on getProperties() which returned only the attributes of the given object. However in case one of these attributes happens to be a JObject instance itself, then JForm::bindLevel would fail there.
In particular model's getItem function tends to return a nested JObject always.
JArrayHelper call would take care of JObject to Array conversion recursively.
http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=33834&start=0