diff --git a/core/modules/node/src/Entity/Node.php b/core/modules/node/src/Entity/Node.php index e5544a2..c9983b3 100644 --- a/core/modules/node/src/Entity/Node.php +++ b/core/modules/node/src/Entity/Node.php @@ -106,6 +106,11 @@ public function preSave(EntityStorageInterface $storage) { } } + // If the node is new, set the changed time as the created time. + if ($this->isNew()) { + $this->setChangedTime($this->getCreatedTime()); + } + // If no revision author has been set explicitly, make the node owner the // revision author. if (!$this->getRevisionUser()) { diff --git a/core/modules/node/tests/src/Functional/NodeCreationTest.php b/core/modules/node/tests/src/Functional/NodeCreationTest.php index 4d24901..5f83ee9 100644 --- a/core/modules/node/tests/src/Functional/NodeCreationTest.php +++ b/core/modules/node/tests/src/Functional/NodeCreationTest.php @@ -58,6 +58,9 @@ public function testNodeCreation() { $node = $this->drupalGetNodeByTitle($edit['title[0][value]']); $this->assertTrue($node, 'Node found in database.'); + // Assert that the changed and created times are the same for new nodes. + $this->assertEqual($node->getCreatedTime(), $node->getChangedTime()); + // Verify that pages do not show submitted information by default. $this->drupalGet('node/' . $node->id()); $this->assertNoText($node->getOwner()->getUsername());