In media.pages.inc, line 36, function media_preview_ajax() the callback ends by die();, it should be exit() instead. It will ensure that PHP will fire the shutdown handlers.
Plus, it would be more elegant to use the delivery callback into the menu item description instead of dying, this would ensure no page at all is rendered without doing any exit() or die().
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | cruft_2x.patch | 470 bytes | arthurf |
| #10 | cruft_removal.patch | 1.2 KB | arthurf |
| #5 | media_remove_die-1085136-5.patch | 1.29 KB | idflood |
Comments
Comment #1
aaron commentedfor that matter, maybe it should follow the format at http://api.drupal.org/api/drupal/modules--file--file.module/function/fil... -- looks like things have improved in d7?
Comment #2
pounardYes that probably should be better, but it seems that you have only one controller (menu callback) to respond to all AJAX requests, and those might be all much different.
Comment #3
JacobSingh commentedAt present, I don't even see where this callback is being used :(
Using the ajax_deliver requires that this be used in conjunction with the AJAX framework AFAICT, which means anything using it expecting "normal" json will fail.
Can we just remove this if it isn't in use anywhere?
Comment #4
dave reidI also don't see where this is being used either. I'll test removing it completely.
Comment #5
idflood commentedI've tried to find a use of this callback and didn't find anything. But I may have missed something. Here is what I've found:
1. The media_preview_ajax callback is called from media.module (line 231)
2. Searching the files for "media/js" didn't lead to anything so I looked for "url:" since media_preview_ajax check for a $_GET variable of this name. I've found that media.library.js makes an ajax call at line 76:
3. getMediaUrl is referenced twice with this:
'getMediaUrl' => url('media/browser/list'),
With these results I simply deleted the menu declaration in media.module and the callback. After a drupal cache clear and some tests I haven't noticed any broken piece.
Comment #6
arthurf commentedI applied patch to 1.x and tested uploading and selecting from library. Both worked fine for me.
Comment #8
ParisLiakos commentedTested against 1.x everything seems to work just fine
Comment #9
dave reidSetting to re-test.
Comment #10
arthurf commentedRe-rolled patch from git
Comment #11
dave reidLooks good then.
Comment #12
arthurf commentedLooks like 2.x already removed media_preview_ajax() so it only needs the menu item removed. Here is a separate patch for 2.x
Comment #13
arthurf commentedComment #14
ParisLiakos commentedTested on 2.x,everything still works
So we have #10 for 1.x and #12 for 2.x
Comment #15
aaron commentedfrom http://drupalcode.org/project/media.git/blobdiff/55a3ab29bb60cdc241fc1a3... :
doesn't work like that anymore. kill it!
Comment #16
arthurf commentedCommitted to 1.x and 2.x