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.
The Problem
FileAddForm normally caches the uploaded file in $form_state, but does not account for the possibility of that file being removed and replaced with a different one. Which means that $form_state may be holding on to a file entity that no longer exists in the database. This causes a fatal error when trying to complete the wizard.
Steps to Reproduce
- Go to /file/add.
- Upload a file and click Next.
- Click Previous and click Remove for the uploaded file.
- Upload another file and click Next.
- Proceed through the wizard. After submitting the final step, you will get a fatal error (call to member function hasTranslation() of a non-object in ChangedItem)
The Fix
When the file element's Remove button is clicked, the cached file should be removed from $form_state.
Comment | File | Size | Author |
---|---|---|---|
file_entity-cached_file_cleanup.patch | 1.8 KB | phenaproxima | |
Comments