Delete translations and original language at the same time can cause error

Created on 12 October 2021, over 3 years ago
Updated 1 April 2025, 1 day ago

Problem/Motivation

#3185468: Improve entity delete action so it deletes translations if selected. introduced the possibility to delete translations.

But if we select the original entity and some of its translations and try to delete, it can break the process by trying to save the entity to delete the translation after having deleted the entity.
This doesn't happen all the time: if the translation is deleted before the original language there is no error.

Encountered error:

The website encountered an unexpected error. Please try again later.Drupal\Core\Entity\EntityStorageException: Update existing 'my_custom_entity' entity while changing the ID is not supported. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 810 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php). Drupal\Core\Entity\EntityStorageBase->save() (Line: 801)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (Line: 339)
Drupal\Core\Entity\EntityBase->save() (Line: 28)
Drupal\views_bulk_operations\Plugin\Action\EntityDeleteAction->execute() (Line: 69)
Drupal\views_bulk_operations\Action\ViewsBulkOperationsActionBase->executeMultiple() (Line: 460)
Drupal\views_bulk_operations\Service\ViewsBulkOperationsActionProcessor->process() (Line: 106)
Drupal\views_bulk_operations\ViewsBulkOperationsBatch::operation() (Line: 295)
_batch_process() (Line: 137)
_batch_do() (Line: 93)
_batch_page() (Line: 55)
Drupal\system\Controller\BatchController->batchPage()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 578)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 57)
Drupal\Core\StackMiddleware\Session->handle() (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 23)
Stack\StackedHttpKernel->handle() (Line: 717)
Drupal\Core\DrupalKernel->handle() (Line: 19)

Steps to reproduce

  • Have a view with one row for each translations.
  • Add the Bulk operation field to this view with "Delete selected entities / translations" action.
  • Select the original language and the translation of an entity
  • Try to use the "Delete selected entities / translations" action

Proposed resolution

Remaining tasks

🐛 Bug report
Status

Active

Version

4.3

Component

Core

Created by

🇫🇷France clement.ferrier

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024