Since a few hours reverting an entity to an older revision that has fewer translations as before leads into a fatal error caused by

Drupal\Core\Entity\EntityStorageException: Invalid translation language (de) specified. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 757 of /Users/mkalkbrenner/git/drupal/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

I assume that this was introduced by #2090983: ContentEntityInterface::getTranslation() should throw an exception when an invalid language is specified.

I attached a patch that includes a failing test to demonstrate the issue.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mkalkbrenner created an issue. See original summary.

vijaycs85’s picture

Issue tags: +D8MI, +sprint

Status: Needs review » Needs work

The last submitted patch, revert_translation_exception.patch, failed testing.

mkalkbrenner’s picture

I just checked locally that the test case succeeds with 4a992013d875942451c89b3692490730bc435c7f but fails with 5c0eb9b7a5021c429f751ed378af9da9eaf9b983.

mkalkbrenner’s picture

I don't think that #2090983: ContentEntityInterface::getTranslation() should throw an exception when an invalid language is specified introduced the issue but simply uncovered the real one.

@plach: I'm not sure yet, but it seems that entity storage iterates over the translations of the latest revision instead of the translations of the revision that is saved.

plach’s picture

Assigned: Unassigned » plach

On this

plach’s picture

Assigned: plach » Unassigned
Status: Needs work » Needs review
FileSize
774 bytes
2.28 KB

This should be it

chx’s picture

Status: Needs review » Reviewed & tested by the community

That looks sensible: the translation we delete must come from the original , it is not on the current one because it is deleted (doh!)

plach’s picture

Exactly, thanks!

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

We have tests and the fix makes sense. Committed 3884a58 and pushed to 8.0.x. Thanks!

  • alexpott committed 3884a58 on 8.0.x
    Issue #2579187 by plach, mkalkbrenner: Revert to an older entity...

The last submitted patch, revert_translation_exception.patch, failed testing.

Gábor Hojtsy’s picture

Issue tags: -sprint +language-content

Woot, thanks folks!

Status: Fixed » Closed (fixed)

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