Problem/Motivation

When deleting a translation of an ECK entity via the standard content translation UI, Drupal throws an exception during the submit phase of the delete confirmation form.

The crash happens when core tries to log the deletion message for a non-default translation. At that point the active translation has already been marked as removed, and ECK’s EckEntity::label() implementation still attempts to access translatable fields on the removed translation. This causes ContentEntityBase::getTranslatedField() to throw an InvalidArgumentException, resulting in a 500 error instead of a clean redirect back to the canonical page.

This behaviour is specific to ECK entities. Node entity translations can be deleted from the UI without errors because their label resolution relies on the core entity key “label” and does not re-access removed translations in the same way.

Relevant stack trace (shortened):

InvalidArgumentException: The entity object refers to a removed translation (ru) and cannot be manipulated. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 609 of core/lib/Drupal/Core/Entity/ContentEntityBase.php).
Drupal\Core\Entity\ContentEntityBase->get('title') (Line: 100)
Drupal\eck\Entity\EckEntity->label() (Line: 116)
Drupal\Core\Entity\ContentEntityDeleteForm->logDeletionMessage() (Line: 76)
Drupal\Core\Entity\ContentEntityDeleteForm->submitForm(Array, Object)
call_user_func_array(Array, Array) (Line: 129)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 67)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 597)
Drupal\Core\Form\FormBuilder->processForm('content_translation_delete_confirm', Array, Object) (Line: 325)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 627)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 54)
Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 53)
Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Error message:

- InvalidArgumentException: The entity object refers to a removed translation (en) and cannot be manipulated.

Steps to reproduce

Assumptions:
- ECK module is enabled.
- You have at least one ECK entity type/bundle (e.g. `grid`, `promo`) that is translatable.
- Content Translation is enabled for that entity type.
- There is at least one non-default translation for a given ECK entity (e.g. `en`, `ru`).

1. Create an ECK entity and add at least one translation (for example, create the entity in English and then add a Russian translation).
2. Go to the translation delete confirmation form for the non-default translation. For example:
- /grid/5/translations/delete/en
- or /promo/1/translations/delete/ru
3. Confirm the deletion by clicking the “Delete [language] translation” button.
4. Observe that instead of successfully deleting the translation and redirecting, Drupal returns a 500 error with the message:

InvalidArgumentException: The entity object refers to a removed translation (en) and cannot be manipulated.

Notes:
- Deleting a node translation via the analogous URL does not produce this error.
- The problem is triggered specifically when core calls $entity->label() from ContentEntityDeleteForm::logDeletionMessage() after the translation has been marked as removed.

Issue fork eck-3579686

Command icon 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

vadim.hirbu created an issue. See original summary.

dieterholvoet’s picture

Status: Active » Closed (duplicate)
Related issues: +#3423205: Deleting a translation causes error when logging the deletion message

Just tried to reproduce this issue but I couldn't. Even if this is an actual issue with the ECK module, catching the exception is more of a workaround than an actual solution. An acceptable solution would be to prevent the exception from being thrown.

I did find the following core issue which seems to describe the same problem: #3423205: Deleting a translation causes error when logging the deletion message

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.