getFileUri() on null in Drupal\media\Entity\Media->getThumbnailUri() AI translate entity reference

Created on 3 January 2025, about 2 months ago

Problem/Motivation

In some cases i get this error when triying to translate content by AI.

Error: Call to a member function getFileUri() on null in Drupal\media\Entity\Media->getThumbnailUri() (line 262 of /var/www/html/web/core/modules/media/src/Entity/Media.php).

This error occur with entity reference translation of media.
This appen when the system try to translate a media wich dont have a file related.
This can appen with the usage of stage_file_proxy module for example, or when you use a database locally without the files for example.

This is is cause by the $referencedEntity->save(); in ReferenceFieldExtractor.php file.

Those are specific case, but it would be good the translation dont stops because of that.

Steps to reproduce

Configure ai translate entity reference to translate media.
Get a node with a media referenced where the file is not exsting for a specific media.

To do that, use stage_file_proxy and/or import a production database locally without the files.
Or also just remove the file related to the media in file system.

Then translate this node by ai and see you got a php error.

Proposed resolution

Catch this issue and log it as error in the logs.

🐛 Bug report
Status

Active

Version

1.0

Component

Other Submodules

Created by

🇧🇪Belgium arwillame Belgium 🇧🇪

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024