Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I am getting this warning after uploading a new file:
Warning: json_encode(): recursion detected in drupal_json_encode() (line 4972 of /var/www/vlw/includes/common.inc).
Any help?
my setup is drupal 7.19, media 7.x-2.x dev, file entity 7.x-2.x dev.
thanks in advance
Comment | File | Size | Author |
---|---|---|---|
#21 | ctools-modal-form-file-editing-1909408-21.patch | 1.6 KB | mrjmd |
#17 | media-fix-ctools-modal-form-file-editing-1909408.patch | 490 bytes | gmclelland |
Comments
Comment #1
gmclelland CreditAttribution: gmclelland commentedThis might be same thing as #1409068: Popup not closing I get this as well and haven't yet figured it out. I'll let the maintainers determine if this is a duplicate or a separate issue.
Let me know if you figure it out.
Comment #2
Jc Denton CreditAttribution: Jc Denton commentedOk thanks.
This is happening when i upload a file and filling the custom fields i created for this file.
If i find anything i' ll post back
Comment #3
gmclelland CreditAttribution: gmclelland commentedI was able to reproduce this on a fresh install with the following basic modules:
projects[ctools][version] = "1.x-dev"
projects[ctools][subdir] = "contrib"
projects[file_entity][version] = "2.x-dev"
projects[file_entity][subdir] = "contrib"
projects[media][version] = "2.x-dev"
projects[media][subdir] = "contrib"
projects[entity][version] = "1.x-dev"
projects[entity][subdir] = "contrib"
projects[views][version] = "3.x-dev"
projects[views][subdir] = "contrib"
Steps to reproduce:
1. Add a file field to the basic page content type change the widget to "Media file selector".
2. Create a basic page node and a file.
3. Save the node.
4. Edit the node.
5. Edit the file and change the "Alt" text.
6. Press save in the ctools modal dialog
7. Save the node
8. Error is shown on node view
After saving the node you will see the error message:
Warning: json_encode(): recursion detected in drupal_json_encode() (line 4972 of /home/quickstart/websites/media.dev/includes/common.inc).
Warning: json_encode(): recursion detected in drupal_json_encode() (line 4972 of /home/quickstart/websites/media.dev/includes/common.inc).
I'm getting this error in a mac environment and a ubuntu environment.
Hope that helps
Comment #4
gmclelland CreditAttribution: gmclelland commentedI wonder if this is somehow related to the following past issues:
#1553114: Adding files should be a multi-step process
specifically see - http://drupal.org/node/1553114#comment-6624650
- sort of seems like the same issues
#1848034: Remove ctools edit form after uploading a new file in media browser
Comment #5
Dave ReidCan someone help put in a debug to see what is getting passed into drupal_json_encode()?
Comment #6
gmclelland CreditAttribution: gmclelland commentedI placed the debug($var);
on the first line of drupal_json_encode() in common.inc
When I click edit on the file field it pops up the ctools modal dialog. I then change the Alt text to something different and hit save.
Immediately I get a js error dialog that says the following and I can't close the dialog unless I click "Close Window":
@Dave Reid - Is that what you are looking for?
Comment #7
gmclelland CreditAttribution: gmclelland commentedThis is what is displayed when I click edit on the file field. The ctools edit file dialog is opened and this is what is shown.
Comment #8
ParisLiakos CreditAttribution: ParisLiakos commentedwell debugged this a bit, and to me it seems the problem is in ctools.
in
media_file_edit_modal
,ctools_modal_form_wrapper
returns a form build array instead of ajax commands..this shouldnt happen, cause media actually sends this array toajax_render
, which guess what..it expects ajax commands^^dunno, what the reason for that is, and i am not a ctools expert, but imo
ctools_modal_form_wrapper
does something wrong.....or media needs extra check on what the array is before sending it over to ajax_render?Comment #9
ParisLiakos CreditAttribution: ParisLiakos commentedlets ask folks over there
Comment #10
ParisLiakos CreditAttribution: ParisLiakos commentedComment #11
gmclelland CreditAttribution: gmclelland commentedThank you @rootatwc for checking into this. Just to note: I did try this with ctools-1.x-dev, 1.2, and 1.1 just to see if the problem was introduced by a new version. Unfortunately the bug is showing in all those versions.
Comment #12
shaisamuel CreditAttribution: shaisamuel commentedThank you @gmclelland. Your #3 process is where I have the same error, using:
Comment #13
gmclelland CreditAttribution: gmclelland commented@rootatwc - I just tested a clean install with the following:
Media 2.0-unstable7
File Entity 2.0-unstable7
Ctools 1.2
I'm not getting any errors with this setup. That's one step closer to finding the problem.
Comment #14
gmclelland CreditAttribution: gmclelland commented@rootatwc - It took me a long time, but I think I found the problem.
The last File Entity module commit that works without errors is http://drupalcode.org/project/file_entity.git/commit/cffe49222253e0426e6...
Starting with this commit, the errors start appearing http://drupalcode.org/project/file_entity.git/commit/2fec0d7ce40fd3fee5f...
Hope that helps
Maybe this issue should be moved to the file_entity issue queue?
At the moment, I'm also testing with Media-2.x 0d2eefc
Comment #15
ParisLiakos CreditAttribution: ParisLiakos commentednope. that commit just exposed the ctools bug i think
Comment #16
merlinofchaos CreditAttribution: merlinofchaos commentedOk, I agree that the doxy for ctools_modal_form_wrapper is out of date, and reflects the Drupal 6 state of form api. In today's world, if successfully executed, it will still return a render array. This did not used to be available.
However, there's still a bug, I think, in the media code:
Even if you take CTools at its word, if the form is executed, $output should be NULL.
That makes $commands[] = ... still invaliad, because you're adding an array to NULL which isn't legal. If $form_state['executed'] is set to TRUE, then $commands should be re-built from scratch. This is especially true because now FAPI will still return a render array which I won't throw away. So CTools function documentation should be adjusted to reflect that it will return the raw render array which you can then do with what you will. (Probably throw away, but there have been times when I've found it *very* useful upon form execution, since data can be stored in it).
I believe changing the
$commands[] =
to$commands = array(
should be sufficient to fix media.
Comment #17
gmclelland CreditAttribution: gmclelland commentedYay! That fixes it. Great catch @merlinofchaos.
Here is the patch against the Media module-2x-dev.
Moving this back to Media issue queue.
Comment #18
ParisLiakos CreditAttribution: ParisLiakos commentedawesome, thanks for the quick patch
Committed and pushed
http://drupalcode.org/project/media.git/commit/5c497f5
Back to ctools, for documentation fix
Comment #21
mrjmd CreditAttribution: mrjmd commentedFrom my reading of this issue, all that's left is a documentation update to ctools function ctools_modal_form_wrapper(). I've rolled and attached a patch.
Comment #22
DamienMcKennaGood to go.
Comment #23
mrjmd CreditAttribution: mrjmd commentedComment #24
japerryLooks good to me. Committed.