Trying to remove an image file from a Media entity results in this error:
Error: Call to a member function language() on null in Drupal\exif\ExifContent->getFileUriAndLanguage() (line 376 of /home/stencilarchive/stencilarchive.org/web/modules/contrib/exif/src/ExifContent.php).
Issue fork exif-3569085
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
codesmithThis happened after upgrading from Drupal 10 to Drupal 11.3
Comment #5
nickolajAdded null check in `getFileUriAndLanguage()` to skip processing when file entity no longer exists (e.g., when image is removed from Media).
Comment #6
damienmckennaThank you for the merge request, we'll add it to the next release.
Comment #7
csakiistvanComment #8
csakiistvanEnvironment
Prerequisites
mediamodule.field_modelto the Image media type and set its widget on the default form display to Exif readonly, with Exif field =naming_conventionand Image field =field_media_image.Steps
getFileUriAndLanguage()skips image field deltas whose referenced file entity is missing instead of dereferencingNULL.ddev drush cr/media/1/editfor the Image media entity created above./admin/reports/dblogfor PHP errors.Expected results
Actual results
Before the fix, pressing Remove aborted the AJAX request with "Oops, something went wrong." and logged
Warning: Trying to access array offset on nullfollowed byError: Call to a member function language() on null in Drupal\exif\ExifContent->getFileUriAndLanguage(), raised fromgetMediaMetadata()inexif_form_alter()during the form rebuild. After the fix the image is removed cleanly, the form rebuilds, the log stays empty, and saving only produces the expected "Image field is required." validation message.Testing produced with the assistance of an LLM.
Comment #10
damienmckennaCommitted. Thank you.