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.

CommentFileSizeAuthor
#8 field_file_usage-1191438-8.patch1.54 KBidflood
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

aaron’s picture

yes, i confirm this is indeed the case (with a file field).

aaron’s picture

Title: file_usage not updated after node deletion » file_usage not updated after removing a file/image field
aaron’s picture

changed 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.

szantog’s picture

I can confirm too, but my question is how to fix consistent in this table? Should write an update hook?

nlambert’s picture

subscribe

CarbonPig’s picture

subscribe

bensnyder’s picture

sub

idflood’s picture

Version: 7.x-dev » 8.x-dev
Status: Active » Needs review
FileSize
1.54 KB

I 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.

Status: Needs review » Needs work

The last submitted patch, field_file_usage-1191438-8.patch, failed testing.

dimitriseng’s picture

I have the same issue, is there any progress with this? Thank you.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

kim.pepper’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)

Closing as outdated. Please re-open if this is still relevant.