I had the following bug in a Drupal 7.2 site today:
- node type X had an image field attached to it
- the file field was removed from the node type X
- I removed node 28 (type X)
- I tried to remove the image that used to be attached to node 28 using the Media module interface (/admin/content/media)
- I got the error message that file deletion was not possible because the file was in use: "The file @title is in use and cannot be deleted."
As it turned out, the file_usage table still contained a row for node 28.
I have not yet tried to reproduce this on a clean install and I hope this is a one-time weirdness caused by some exotic edge case. However if more people see this bug, let's find out what's causing it.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | field_file_usage-1191438-8.patch | 1.54 KB | idflood |
Comments
Comment #1
aaron commentedyes, i confirm this is indeed the case (with a file field).
Comment #2
aaron commentedComment #3
aaron commentedchanged the title, as the file_usage table should be updated for all nodes that had the field when the field is removed, not just on the node deletion.
Comment #4
szantog commentedI can confirm too, but my question is how to fix consistent in this table? Should write an update hook?
Comment #5
nlambert commentedsubscribe
Comment #6
CarbonPig commentedsubscribe
Comment #7
bensnyder commentedsub
Comment #8
idflood commentedI confirm this also happens in drupal 8 so changing the version of the issue. I don't know if the "Needs backport" has to be added now or when a patch has been commited so leaving it for others.
Here is a first patch that adds a basic test to highlight the issue. If you have idea of better naming/comments and place where it should be don't hesitate, I'm not inspired for that.
Comment #10
dimitriseng commentedI have the same issue, is there any progress with this? Thank you.
Comment #17
kim.pepperClosing as outdated. Please re-open if this is still relevant.