To Reproduce:
- Tested on 7.8 and 7.x-dev with PECL uploadprogress PHP module, Chrome and FF with no dev modules or extensions
- Add a form with a managed file upload element and use the 'bar' progress indicator.
- Upload a file
This generates an AJAX error. The response is printed in the error message. The response is an obviously corrupt json string of the form:
{ progress bar info from file_ajax_progress() } [{other ajax commands}]
The prettied up json is attached.
The Likely Cause?
I'm very new to the web designing thing but as far as I can tell, file_ajax_progress() is supposed to return an ajax command array and it doesn't. It returns nothing. Instead, it echos out the progress bar message and percentage directly. ajax_deliver() then appends the other commands and creates a bad json string with 2 arrays butted together.
Am I crazy? I've tried making file_ajax_progress() return it's $progress array (in various ways) instead of echoing it. This removes the error but the progress bar doesn't appear (although the divs are inserted for it).
Next Action
Can anyone confirm this or point me in the right direction?
Thanks muchly
Comment | File | Size | Author |
---|---|---|---|
#8 | upload-progress-file-progressproblems-1316252-8.patch | 273 bytes | j0rd |
json.txt | 2.35 KB | noland |
Comments
Comment #1
marcingy CreditAttribution: marcingy commentedYour json shows the module colourbox which is not part of core. Please disable all none core modules and see if the problem still exists.
Comment #2
noland CreditAttribution: noland commentedOk. Installed a fresh minimal 7.x-dev site. Added a module containing only code found below:
Created a new content type on page, "basic_page", and try to add/edit this content. The following error is generated on each upload for Chrome, FF, IE 8 (with no extensions, no firebug):
(white space added for readability)
This error apparently only affect display of the progress bar. The file is uploaded and is intact and the managed file table is updated properly. You can also "remove" the file with the managed file widget with no errors. If #progress_indicator is set to throbber, there is no error. Again, I'm using PECL uploadprogress, not APC.
This site is available at www.locat.ca and anon users can create this content and see the error.
What should I do next?
Thanks for your help
Comment #3
marcingy CreditAttribution: marcingy commentedComment #4
quicksketchI've confirmed this problem on Drupal 7.8 while using the APC upload progress indicator. There's definitely something up with our progress bar.
Comment #5
quicksketchOh, actually 7.8 is *totally* busted due to #935208-141: PECL uploadprogress bar doesn't appear.. I'll upgrade to 7.10 and try again.
Comment #6
quicksketchThis issue has been fixed in Drupal 7.10 (and 8.x) by the issue mentioned in #5. Note that you have to both upgrade and manually clear the cache if you use drush for the update.
Comment #7
j0rd CreditAttribution: j0rd commentedI'm getting this error (comment #2) in Drupal 7.15.
I have both Upload Progress (1.0.3.1) installed and APC (3.1.3p1) installed.
If I disable APC, I still get the error.
If I disable Upload Progress, the error goes away.
Still seems to be some kind of problem.
Exact same error as listed above, as two AJAX requests seem to be getting sent and are not valid json. I assume this is because Upload Progress is injecting it's json into the request, and so is Drupal.
I'm also using the upload in a jquery-ui modal (Media Module 2.x & File Entity).
Comment #8
j0rd CreditAttribution: j0rd commentedSo as mentioned, I'm getting the same problems as comment #2, where Drupal is injecting addition JSON after the file_ajax_progress() function is called.
I assumed, this is because the function doesn't exit. I could be wrong, but in the past on D6, after you print your JSON to STDOUT, you usually exit right after. This isn't happening in file_ajax_progress() and additional Drupal ajax is getting appended to the request.
I've tried adding ajax_footer() at the end instead of exit; and I continue to get the same invalid json response.
Here's a patch which seems to resolve this issue for me. Please take a look and see if you believe this is correct, or if it would cause other errors.
Comment #9
j0rd CreditAttribution: j0rd commentedre-opening this issue.
Comment #10
silinor CreditAttribution: silinor commented#8 patch works for me
Comment #11
quicksketchDrupal core certainly doesn't inject additional JSON, it's probably caused by a particular module that isn't behaving correctly. Drupal shouldn't need to be forcefully exit()'d, and adding an explicit exit() will cause hook_exit() to be skipped. You should try to find which module is adding the additional JSON and correcting the problem with that module.
Comment #11.0
quicksketchcorrected typo
Comment #12
webservant316 CreditAttribution: webservant316 commentedI am seeing this error with Drupal 7.56 and PHP71. Problem goes away with PHP70. Any tips on how to find the problem module adding extra JSON?