Unverified Commit 895db7dd authored by larowlan's avatar larowlan

Issue #2934517 by Berdir: Setting a revision ID on a new entity sets the newRevision flag to false

parent 128cb262
......@@ -768,7 +768,7 @@ public function onChange($name) {
// If the revision identifier field is being populated with the original
// value, we need to make sure the "new revision" flag is reset
// accordingly.
if ($key === 'revision' && $this->getRevisionId() == $this->getLoadedRevisionId()) {
if ($key === 'revision' && $this->getRevisionId() == $this->getLoadedRevisionId() && !$this->isNew()) {
$this->newRevision = FALSE;
}
}
......
......@@ -256,6 +256,16 @@ public function testNewRevisionRevert() {
$this->assertNull($entity->getRevisionId());
$this->assertEquals($revision_id, $entity->getLoadedRevisionId());
$this->assertTrue($entity->isNewRevision());
// Check that calling setNewRevision() on a new entity without a revision ID
// and then with a revision ID does not unset the revision ID.
$entity = EntityTestMulRev::create(['name' => 'EntityLoadedRevisionTest']);
$entity->set('revision_id', NULL);
$entity->set('revision_id', 5);
$this->assertTrue($entity->isNewRevision());
$entity->setNewRevision();
$this->assertEquals(5, $entity->get('revision_id')->value);
}
}
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