Skip to content
Snippets Groups Projects
Commit 3884a586 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2579187 by plach, mkalkbrenner: Revert to an older entity revision with...

Issue #2579187 by plach, mkalkbrenner: Revert to an older entity revision with less translations leads to fatal error caused by EntityStorageException
parent 0e4c0f30
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -336,7 +336,7 @@ protected function invokeTranslationHooks(ContentEntityInterface $entity) {
$this->invokeHook('translation_insert', $entity->getTranslation($langcode));
}
elseif (!isset($translations[$langcode]) && isset($original_translations[$langcode])) {
$this->invokeHook('translation_delete', $entity->getTranslation($langcode));
$this->invokeHook('translation_delete', $entity->original->getTranslation($langcode));
}
}
}
......
......@@ -57,4 +57,39 @@ public function testNewRevisionAfterTranslation() {
$this->assertTrue($this->reloadEntity($entity)->getRevisionId() > $old_rev_id, 'The entity from the storage has a newer revision id.');
}
/**
* Tests if the translation object has the right revision id after new revision.
*/
public function testRevertRevisionAfterTranslation() {
$user = $this->createUser();
$storage = $this->entityManager->getStorage('entity_test_mulrev');
// Create a test entity.
$entity = EntityTestMulRev::create([
'name' => $this->randomString(),
'user_id' => $user->id(),
'language' => 'en',
]);
$entity->save();
$old_rev_id = $entity->getRevisionId();
$translation = $entity->addTranslation('de');
$translation->setNewRevision();
$translation->save();
$entity = $this->reloadEntity($entity);
$this->assertTrue($entity->hasTranslation('de'));
$entity = $storage->loadRevision($old_rev_id);
$entity->setNewRevision();
$entity->isDefaultRevision(TRUE);
$entity->save();
$entity = $this->reloadEntity($entity);
$this->assertFalse($entity->hasTranslation('de'));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment