Issue #3001299 by seanB, joseph.olstad, damondt, amateescu: Error Loading Language Not Translated For Current Revision
parent
ffd99ca739
commit
5cbd58e6a3
|
@ -157,7 +157,7 @@ class ModerationInformation implements ModerationInformationInterface {
|
||||||
$latest_revision_id = $storage->getLatestTranslationAffectedRevisionId($entity->id(), $entity->language()->getId());
|
$latest_revision_id = $storage->getLatestTranslationAffectedRevisionId($entity->id(), $entity->language()->getId());
|
||||||
$default_revision_id = $entity->isDefaultRevision() && !$entity->isNewRevision() && ($revision_id = $entity->getRevisionId()) ?
|
$default_revision_id = $entity->isDefaultRevision() && !$entity->isNewRevision() && ($revision_id = $entity->getRevisionId()) ?
|
||||||
$revision_id : $this->getDefaultRevisionId($entity->getEntityTypeId(), $entity->id());
|
$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 */
|
/** @var \Drupal\Core\Entity\ContentEntityInterface $latest_revision */
|
||||||
$latest_revision = $storage->loadRevision($latest_revision_id);
|
$latest_revision = $storage->loadRevision($latest_revision_id);
|
||||||
$result = !$latest_revision->wasDefaultRevision();
|
$result = !$latest_revision->wasDefaultRevision();
|
||||||
|
|
|
@ -151,7 +151,38 @@ class ModerationInformationTest extends KernelTestBase {
|
||||||
// language in a draft state and a non-default language in a published
|
// 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
|
// state. The method returns TRUE if any of the languages for the default
|
||||||
// revision are in a published state.
|
// 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));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue