Commit 3884a586 authored by alexpott's avatar alexpott

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
......@@ -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'));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment