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.
Problem/Motivation
Lots of errors when file is deleted that was referred to from a node and then the node is deleted.
Steps to reproduce
- Create a content type
- Add a file field to the content type
- Create a node of that content type and upload a file to the file field
- Go to the file admin page: admin/content/file
- Delete the file
- Go to the content admin page: admin/content
- Delete the node
- You should see errors like below
Notice: Undefined property: stdClass::$fid in file_usage_list() (line 615 of /xyz/includes/file.inc).
Notice: Undefined property: stdClass::$status in file_field_delete_file() (line 348 of /Users/kristen/sites/my-site/modules/file/file.field.inc).
Notice: Undefined property: stdClass::$fid in file_usage_delete() (line 694 of /xyz/includes/file.inc).
Notice: Undefined property: stdClass::$uri in file_delete() (line 1237 of /xyz/includes/file.inc).
Notice: Undefined property: stdClass::$uri in file_delete() (line 1238 of /xyz/includes/file.inc).
Notice: Undefined property: stdClass::$uri in file_delete() (line 1242 of /xyz/includes/file.inc).
Notice: Undefined property: stdClass::$uri in file_delete() (line 1244 of /xyz/includes/file.inc).
The specified file could not be deleted, because it is not a valid URI. More information is available in the system log.
Proposed resolution
Not sure. Should we be able to delete the file if it is being referenced? If so, should it automatically remove it from all entities that reference it?
Remaining tasks
- Figure out best approach
- Implement it!
User interface changes
n/a
API changes
n/a
Comments
Comment #1
Kristen PolComment #1.0
Kristen Poltypo
Comment #1.1
aimeeraeremoved path info
Comment #2
thirupathi43 CreditAttribution: thirupathi43 commentedHi Kristen Pol ,
Is there any update to fix those errors???????
Comment #3
besja CreditAttribution: besja commentedHi,
We have the same error. Is there any solution?