Active
Project:
Drupal core
Version:
main
Component:
file system
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
9 Nov 2016 at 16:51 UTC
Updated:
22 Jul 2025 at 14:17 UTC
Jump to comment: Most recent
Comments
Comment #2
catchAt least major if not critical.
Comment #4
xjmYeah I think this is critical, since it will also result in unexpected deletion of the files.
Comment #5
effulgentsia commentedIn #2831274-200: Bring Media entity module to core as Media module, I suggested removing the ability to make ER fields to file entities. Here's what I said in that comment:
There was a UX call following that comment where people on the UX team +1'd that suggestion, but I don't have the link to that recording at the moment (though I can dig it up if needed).
However, we don't have Media field in core yet, and even once we do, I don't know if we have sufficient consensus on removing ER fields to file entities. So, I don't know if we want to fix this issue by making usage tracking work, or if we want to "fix" it by removing ER fields to files.
Comment #6
effulgentsia commentedI discussed this with @xjm, @catch, @alexpott, and @cottser. We agreed to keep this Critical for now, since it is a data integrity bug, so tagging it as triaged.
#2821423: Dealing with unexpected file deletion due to incorrect file usage is the issue for dealing with all the file usage problems more systemically, but that's a Plan issue for now, so the individual bugs are still independent issues.
#2862461: When adding a reference field, remove "File" from the offered entity types is the issue for deprecating ER fields to file entities in favor of using Media fields instead, per #5. However, while we can remove the capability from the UI, we'll still need to deal with BC for sites that already have this.
Therefore, this issue still needs to be addressed.
Comment #7
wim leersBut that'd be breaking the integrity of the data modeling capabilities of Drupal. It'd also be a BC break.
Here's an alternative proposal:
FileFieldItemList::postSave()+FileFieldItemList::delete()+FileFieldItemList::deleteRevision()tohook_entity_insert()+hook_entity_update()+hook_entity_delete()+hook_entity_revision_delete()implementations owned by thefilemoduleinstanceof EntityReferenceFieldItemList, i.e. for every entity reference fieldComment #8
catchNow that #2801777: Give users the option to prevent drupal from automatically marking unused files as temporary is in, this no longer results in unexpected file deletion. #2821423: Dealing with unexpected file deletion due to incorrect file usage is open as a critical meta-issue to discuss the broader approach on this. So I'm going to downgrade this to major after discussion with @xjm and @cilefen, since we feel effort would be better spent on replacing the file_usage system at this point. We can still fix this bug of course as a major.
Comment #16
quietone commentedUpdate IS.
Comment #20
smustgrave commentedBelieve this is still a valid issue, tested by
Standard profile install
Add a reference field to the Article content type
Using other > select file
Uploaded a file on another node
Verified the usage is 1
Created an Article that references that file I uploaded
Usage is still 1.
Comment #22
arjenk commentedadded a unittest that confirms the tested scenario. The suggestion in https://www.drupal.org/project/drupal/issues/2826127#comment-12156312 will likely fix the issue, although after reading #2821423, this seems not the way to go.