Problem/Motivation
During the AJAX request a form may be rebuilt.
If an element has attached Drupal.settings, it may be added twice (for the same identifier).
Thus, when file_ajax_upload() merges these settings, it does so using array_merge_recursive() and turns scalar values into arrays of scalar values.
This results in the JS engine halting with the error:
TypeError: element_settings.url.replace is not a function
Proposed resolution
Use drupal_array_merge_deep() instead.
Remaining tasks
- Create a patch
User interface changes
None
API changes
None
Data model changes
None
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | file_ajax_upload-2870289-6.patch | 604 bytes | David_Rothstein |
| #2 | file_ajax_upload-2870289-2.patch | 974 bytes | markhalliwell |
Comments
Comment #2
markhalliwellComment #3
hass commentedI can confim the patch solve the issue in file module.
Aside, I also get this views carousel (
views_bootstrapmodule) issue:Comment #4
oriol_e9gYes, same problem and this fixs works in my case. RTBC+
Comment #5
stefan.r commentedComment #6
David_Rothstein commentedLooks good - interesting that no one noticed this before since we fixed the other settings-merging code to do this years ago!
I think it would be nicer to use drupal_array_merge_deep_array() here, though, since that's what all the other settings-merging code does and because it looks cleaner. Here's a patch that does this. I'm leaving it RTBC since I'm positive it's the exact same thing, but it would be good for someone else to do a quick review before committing it.
Comment #7
David_Rothstein commentedRemoving issue credit from myself, since my contribution to this was extremely minimal.
Comment #9
David_Rothstein commentedComment #11
stefan.r commentedCommitted and pushed to 7.x, thanks!