Commit 5cbd58e6 authored by alexpott's avatar alexpott

Issue #3001299 by seanB, joseph.olstad, damondt, amateescu: Error Loading...

Issue #3001299 by seanB, joseph.olstad, damondt, amateescu: Error Loading Language Not Translated For Current Revision
parent ffd99ca7
......@@ -157,7 +157,7 @@ public function hasPendingRevision(ContentEntityInterface $entity) {
$latest_revision_id = $storage->getLatestTranslationAffectedRevisionId($entity->id(), $entity->language()->getId());
$default_revision_id = $entity->isDefaultRevision() && !$entity->isNewRevision() && ($revision_id = $entity->getRevisionId()) ?
$revision_id : $this->getDefaultRevisionId($entity->getEntityTypeId(), $entity->id());
if ($latest_revision_id != $default_revision_id) {
if ($latest_revision_id !== NULL && $latest_revision_id != $default_revision_id) {
/** @var \Drupal\Core\Entity\ContentEntityInterface $latest_revision */
$latest_revision = $storage->loadRevision($latest_revision_id);
$result = !$latest_revision->wasDefaultRevision();
......
......@@ -151,7 +151,38 @@ public function testIsDefaultRevisionPublishedMultilingual() {
// language in a draft state and a non-default language in a published
// state. The method returns TRUE if any of the languages for the default
// revision are in a published state.
$this->assertEquals(TRUE, $this->moderationInformation->isDefaultRevisionPublished($entity));
$this->assertTrue($this->moderationInformation->isDefaultRevisionPublished($entity));
}
/**
* @covers ::hasPendingRevision
*/
public function testHasPendingRevision() {
$entity = EntityTestMulRevPub::create([
'moderation_state' => 'published',
]);
$entity->save();
// Add a translation as a new revision.
$translated = $entity->addTranslation('de');
$translated->moderation_state = 'published';
$translated->setNewRevision(TRUE);
// Test a scenario where the default revision exists with the default
// language in a published state and a non-default language in an unsaved
// state.
$this->assertFalse($this->moderationInformation->hasPendingRevision($translated));
// Save the translation and assert there is no pending revision.
$translated->save();
$this->assertFalse($this->moderationInformation->hasPendingRevision($translated));
// Create a new draft for the translation and assert there is a pending
// revision.
$translated->moderation_state = 'draft';
$translated->setNewRevision(TRUE);
$translated->save();
$this->assertTrue($this->moderationInformation->hasPendingRevision($translated));
}
}
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