Problem/Motivation

When selecting an entity and one or more of its translations and then executing "Delete selected entities / translations" while having one of the translations ordered after the original entity, an exception will be thrown:

Drupal\Core\Entity\EntityStorageException: Update existing 'ENTITY_TYPE_ID' entity while changing the ID is not supported. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 815 of /app/docroot/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

This is because the delete action will be executed on the original entity first. See the related issue that orders the entities based on the view base field.

Steps to reproduce

Try to sort the view result in a way that makes the translated entity appears after the original one.

Proposed resolution

I attached a patch that catches this exception and suppresses it because the translation will be deleted anyway.
However, there could be a better solution where we don't even try to delete the translations if the original entity is included in the selection, or we can somehow ensure that the entities are sorted in a proper order where the original entity is the last one.

Comments

RedwanJamous created an issue. See original summary.

hkirsman’s picture

That helped, tx!

eyad alanati’s picture

Version: 4.2.x-dev » 4.0.1
Assigned: Unassigned » eyad alanati
StatusFileSize
new1.61 KB

i tried the above patch for version 4.0.1 and it didn't worked out so i made on compatible for the mentioned version.

odai jbr’s picture

StatusFileSize
new1.15 KB

a re-roll for patch #3 for version 4.2.x.

odai jbr’s picture

Ignore #4

odai jbr’s picture

StatusFileSize
new1.12 KB

a re-roll for patch #3 for version 4.2.x.

chuyenlv’s picture

StatusFileSize
new1.61 KB

Re-roll patch from #3

rajab natshah’s picture

Assigned: eyad alanati » Unassigned
Status: Needs review » Reviewed & tested by the community

Thank you, Chuyen.
Patch #7 is working

  • Graber committed 61c6c836 on 4.2.x
    Issue #3334229 by Odai Jbr, Redwan Jamous, eyad alanati, chuyenlv, Rajab...
graber’s picture

Status: Reviewed & tested by the community » Fixed

Thanks all!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.