Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This is what I think is happening:
- I remove an image (actually a user picture)
- I upload the removed image with the same source file. Call this
FILE_A.jpg
- So now
/admin/content/files
shows two lines:FILE_A.jpg
with a use count of zero: the recently deleted User PictureFILE_A.jpg
with a use count of 1: the newly uploaded User Picture
- Come the next day and
FILE_A.jpg
is not rendered. It's not in the files/styles directory any more. It's been gc'd. - But there's still a line in
/admin/content/files
sayingFILE_A.jpg
's status is "permanent".
Is it reasonable to expect this replacement of one image with an image with the same file name to work without error? Are there other situations - e.g. a race condition - that could also cause this confusion?
Comment | File | Size | Author |
---|---|---|---|
Files___Bradford_Abbas_β_Website.png | 40.75 KB | iainH |
Comments
Comment #2
swentel CreditAttribution: swentel commentedIn the end it might be a file.module problem .. :)
I'll try to write a test for it to see if we can reproduce it.
Comment #3
iainH CreditAttribution: iainH as a volunteer commentedThanks. There's something funny going on - AFAIR Drupal 7 used to append a suffix if a file was uploaded more than once. But what I see elsewhere on the same site: two separate lines in
/admin/content/files
for another file:FILE_B.jpg
.I am wondering what happens when one of those is removed from the site. Each one has a use count of one. So when somebody removes their
FILE_B.jpg
, its use count will go to zero; the image will be gc'd; the other use ofFILE_B.jpg
will still have a use count of one but will probably look for the gc'd image file in vain.I expect Drupal is doing something more sophisticated to identify different files with the same name ... in different or the same directories (determined by default by year and month) ... but in this case it looks like something is slipping through.
Then there is the lifecycle of the thumbnails etc. styles generated from the original images ... head spins ... gives up for the night.
Comment #4
BerdirThe suffix is only added on the stored file, not the saved file name. If you have such duplicates, check if they have different file names on the file system.
There's nothing sophisticated going on as far as I know. Two files, different filenames on storage (uri), same filename in UI, different UUID. Only the UUID is used by e.g. editor.module to track and identify embedded files.
Comment #5
Wim LeersI suspect and hope so.
Comment #6
Wim LeersLooks like it's a bug in
editor.module
after all. @Berdir found the root cause at #2725415-5: Text Editor module fails to track usage of images uploaded in text_with_summary fields, allows uploaded images to be deleted.Comment #7
xjmI'm not sure how a bug in
editor.module
could cause the deletion of user pictures?This does look like a pure duplicate of #2666700: User profile images unexpectedly deleted though, so leaving this closed as duplicate and promoting that one.