Deleting a translation causes error when logging the deletion message

Created on 22 February 2024, 4 months ago

Problem/Motivation

When deleting a translation of an entity I encounter an error

InvalidArgumentException: The entity object refers to a removed translation (fr) and cannot be manipulated. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 576 of core/lib/Drupal/Core/Entity/ContentEntityBase.php).
Drupal\Core\Entity\ContentEntityBase->get('title') (Line: 1311)
Drupal\Core\Entity\ContentEntityBase->getEntityKey('label') (Line: 1262)
Drupal\Core\Entity\ContentEntityBase->label() (Line: 116)
Drupal\Core\Entity\ContentEntityDeleteForm->logDeletionMessage() (Line: 76)
Drupal\Core\Entity\ContentEntityDeleteForm->submitForm(Array, Object)
call_user_func_array(Array, Array) (Line: 114)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 597)

This happens because in the logDeletionMessage() function we try to access the label of a deleted translation.

Steps to reproduce

Delete a translation for an entity (not the default translation).

Proposed resolution

We already have $message which is the value returned from getDeletionMessage(). We should just log this message, we already send it via the messenger service.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Needs work

Version

10.1 ✨

Component
EntityΒ  β†’

Last updated 1 minute ago

Created by

πŸ‡¬πŸ‡§United Kingdom mjmorley

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

Comments & Activities

Production build 0.69.0 2024