Using Media Browser Plus 7.x-2.x-dev I was unable to delete media files from the browser interface. The deletion confirmation page listed no files, and clicking the "Delete" button to confirm produced this:
Undefined index: files in file_multiple_delete_form_submit() (line 432 of .......sites/all/modules/file_entity/file_entity.pages.inc).
It turned out to be an issue with file_entity's file_entity_multiple_delete_confirm_operation function on line 837 of file_entity.module:
function file_entity_multiple_delete_confirm_operation($fids) {
...
}
The $fids variable was always empty. However when I changed it to this:
function file_entity_multiple_delete_confirm_operation($form, $form_state, $fids) {
...
}
then everything worked fine. I'm not too sure what the procedure is now with patches (whether it's all about the diff files or git patches) so I've wussed out & left it alone :)
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | media_browser_plus-fix_multiple_delete-1660918-13.patch | 2.14 KB | Jackinloadup |
| #11 | media-list-delete-confirm.PNG | 33.22 KB | emptyvoid |
| #5 | media_browser_plus-fix_multiple_delete-1660918.patch | 788 bytes | viggo |
Comments
Comment #1
dave reidI'm unable to reproduce this issue with just File entity installed, so it must actually be Media Browser Plus that is causing the issue.
Comment #2
Sunlight Studios commentedI am not sure which other modules use this functionality apart from Media Browser Plus, so I can't test it with anything else. However Media Browser Plus uses it in this context:
If file_entity_multiple_delete_confirm_operation is indeed designed to be used with drupal_get_form then it should include $form and $form_state in its parameter list - see http://api.drupal.org/api/drupal/includes%21form.inc/function/drupal_get... (or indeed other functions called by drupal_get_form in the core code)
I am assuming this is the case so I'm bouncing it back to the file_entity project, if I've got it totally wrong then plonk it back to Media Browser Plus & slap me :)
Comment #3
Sunlight Studios commentedComment #4
dave reidThe form ID changed in 7.x-2.x for deleting multiple files and needs to be fixed in the branch of Media Browser Plus which is compatible with Media 2.x only.
Note that the $files needs to be an array of actual file objects from file_load_multiple() and not an array of just file IDs as well.
Comment #5
viggo commentedI've created a patch from what Dave Reid wrote in comment #4.
Deleting multiple files now works for me.
Comment #6
emptyvoid commentedI am having problems with both list and thumbnail deletion..
more there: http://drupal.org/node/1679604
Comment #7
viggo commentedTry doing what Dave Reid describes in #4.
Or you can even check out the patch in #5.
Notice that the method referenced should be file_multiple_delete_form, and not file_entity_multiple_delete_confirm_operation.
Also, when referencing file_multiple_delete_form, files must be loaded with file_load or file_load_multiple.
Comment #8
emptyvoid commentedUnfortunately file_entity changed the method names and method descriptor to include a different set of parameters. So the methods don't interact correctly any longer.
The target method:
/modules/file_entity/file_entity.pages.inc
As you see here the method expects 3 parameters not 1.
I'll spend some time and step through each method to determine what objects/arrays are required for the method to properly target and delete the entity record and media file. I'll post my research notes as I refactor the module.
I should mention that the delete on the list view and the thumbnail view don't work at all (I'd assume both use the base base functions for deleting the entity and media file). At least that is my hope, if I fix the main methods then all GUI displays should be fixed (crosses fingers).
Comment #9
emptyvoid commentedOk, that's crazy.
So on a lark I redownloaded the 2.x-dev branch and applied the patch as mentioned in #5. Now file deletion is possible on the "thumbnails" display however the "list" display still errors.
On submission of one or more files the confirmation screen displays:
I can however submit via the "delete" button.. doing so deletes the selected file, however I get the following error on the index page.
I'll review code and try to track down the nature of the warnings.
Comment #10
Jackinloadup commentedAs stated above patch in #5 get thumbnail view working but not list view.
Comment #11
emptyvoid commentedThe first error is a two part issue.
1) Confirm Display
I believe the display template being called isn't the correct display expected.
You will notice I highlight GUI elements I think do not belong in a deletion confirm display. The operations element above is what is causing the warning error to occur.
The line that causes the error to occur is below.
media_browser_plus/includes/file_entity.admin.inc
Basically this is targeting a multi-dimensional array of values that should be used to render into the drop down of the "Operations" form. Clearly this form and the footer should not be on this page.
As I mentioned before clicking the "Delete" button does delete the file. So the operation still occurs as desired.
Comment #12
emptyvoid commentedThe following removes the display of the header and footer on the list page.
Current code
Fixed
This change fixes the two sets of bugs entirely!
The second set of errors were triggered as a direct result of the form elements being included in the post-back to the server. The script didn't know what to do with the extra form elements.
By suppressing the form elements during the "Deletion" operation the entity_file module can do it's job.
Comment #13
Jackinloadup commentedHere is a patch of the suggested solution in #12 rolled into #5.
The result is as desired from my quick testing.
Comment #14
das-peter commentedOh nice! I already fixed the deletion partially (the easy part in the thumbnail view ;) ) but then I luckily found this patch.
Applied, extended and committed: http://drupalcode.org/project/media_browser_plus.git/commit/fa2daf73599c...
Comment #16
drdam commentedHi,
I using :
File entity : 7.x-2.0-unstable7 - 2012-11-18
Media : 7.x-2.0-unstable7 - 2012-11-18
Media Browser Plus for Media 2.x : 7.x-2.x-dev - 2012-10-30
When I want to dellete multiple files, I had this error message :
In fact , the bug are produce by Media Browser Plus in media_browser_plus.pages.inc on line 54-55
Or in file_entity.pages.inc line 450, the function is "file_entity_multiple_delete_form".
After remlacing it in media_browser_plus.pages.inc, the bug is solved