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

  1. Go to /file/add.
  2. Upload a file and click Next.
  3. Click Previous and click Remove for the uploaded file.
  4. Upload another file and click Next.
  5. 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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

phenaproxima created an issue.