If a file is used in a field, can't delete from admin/content/media. It's ok.
Get this this message: The file accomodation_0.jpg is in use and cannot be deleted.

If I have lots of media, lots of content, I've never can figured out, in which content was this media used.

With this patch we get more useful warning message, linked to the related content. If this happends (i think..): #1240834: Cannot delete images added via an image field on an entity, what is previously deleted, the message appears as error, and print out the wrong id. (I don't know, is this useful or not, i will start debug my case soon..)

Comments

szantog’s picture

Status: Active » Needs review
StatusFileSize
new1.64 KB

and patch.

Status: Needs review » Needs work

The last submitted patch, 1274524_1_better_warning_message.patch, failed testing.

mlncn’s picture

Status: Needs work » Needs review

The patch applies fine for me-- and according to the test bot, it applied for them too.

[16:24:13] Command [git apply --check -p0 /var/lib/drupaltestbot/sites/default/files/review/1274524_1_better_warning_message.patch 2>&1] succeeded
  Duration: 0 seconds
  Directory: [/var/lib/drupaltestbot/sites/default/files/checkout/sites/default/modules/media]
  Completion status: [0]
  Output: no output.
[16:24:13] Encountered error on [apply], details:
array (
  '@filename' => '1274524_1_better_warning_message.patch',
  '@reason' => 'See the log in the details link for more information',
)

And then it claims it is a MySQL error, the patch fails to apply? Makes no sense, hitting the re-test button.

mlncn’s picture

Status: Needs review » Needs work

The last submitted patch, 1274524_1_better_warning_message.patch, failed testing.

szantog’s picture

Status: Needs work » Needs review
StatusFileSize
new1.64 KB

I can't figured, why failed.. I try to upload as new, if it isn't succes, i will appy a D5 suffix to bypass bot.

Status: Needs review » Needs work

The last submitted patch, 1274524_6_better_warning_message.patch, failed testing.

szantog’s picture

Status: Needs work » Needs review
StatusFileSize
new1.64 KB

ok, just wind the bot up

mlncn’s picture

Priority: Normal » Major
StatusFileSize
new2.53 KB

There are two places where a file can be reported as non-deletable due to being referenced by other content (or revisions thereof). Therefore, the attached patch extracts szantog's work into a helper function and calls it from both places.

Bumping the priority because even after explaining the situation a month ago, our client asked for help with why they could not delete this or that file— this is a significant administrator experience problem.

Status: Needs review » Needs work

The last submitted patch, 1274524_1_better_warning_message-9.patch, failed testing.

Niklas Fiekas’s picture

Subscribe.

carole’s picture

subscribe

reg’s picture

I started using the media module today and came across this issue. Given I have only been using it for a few hours it seems like a weakness in the module that definitely needs addressing.

In my case it's telling me that I cannot delete some files because they are in use and yet when I look for where it is being used I cannot see it as such anywhere. After looking through the DB I think a couple of the files are marked as used without actually being so, so I removed them from DB table and file system.

Even if all the module could do is give links of ID's like fid:123 in use by nodes:567, 569... & entity: 5, 9... etc. that would still be a great help beyond what it does now. I suspect this functionality will also help find and fix the odd bug with the extra information we'll have from it.

dave reid’s picture

Status: Needs work » Closed (duplicate)

This no longer applies. Admins can delete files even if they are in use due to #1422296: Allow a file to be deleted forcefully in delete callbacks. Also see #1286508: Provide a file usage report tab at file/%file/usage.