From 04763af7835aad3eb7b0824ef73db50c92f1aced Mon Sep 17 00:00:00 2001 From: Denny Lubitz Date: Wed, 9 Oct 2024 17:29:39 +0200 Subject: [PATCH] BUGFIX: Force direct access on setting node properties in node data similarize --- .../Classes/Domain/Model/NodeData.php | 2 +- .../Tests/Unit/Domain/Model/NodeDataTest.php | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Neos.ContentRepository/Classes/Domain/Model/NodeData.php b/Neos.ContentRepository/Classes/Domain/Model/NodeData.php index c80d2c816e1..eec8da9c21e 100644 --- a/Neos.ContentRepository/Classes/Domain/Model/NodeData.php +++ b/Neos.ContentRepository/Classes/Domain/Model/NodeData.php @@ -774,7 +774,7 @@ public function similarize(AbstractNodeData $sourceNode, $isCopy = false) $propertyNames[] = 'removed'; } foreach ($propertyNames as $propertyName) { - ObjectAccess::setProperty($this, $propertyName, ObjectAccess::getProperty($sourceNode, $propertyName)); + ObjectAccess::setProperty($this, $propertyName, ObjectAccess::getProperty($sourceNode, $propertyName), true); } $contentObject = $sourceNode->getContentObject(); diff --git a/Neos.ContentRepository/Tests/Unit/Domain/Model/NodeDataTest.php b/Neos.ContentRepository/Tests/Unit/Domain/Model/NodeDataTest.php index ae5851f639f..06bf60c2e95 100644 --- a/Neos.ContentRepository/Tests/Unit/Domain/Model/NodeDataTest.php +++ b/Neos.ContentRepository/Tests/Unit/Domain/Model/NodeDataTest.php @@ -667,6 +667,27 @@ public function similarizeClearsPropertiesBeforeAddingNewOnes() self::assertEquals($expectedProperties, $this->nodeData->getProperties()); } + /** + * @test + */ + public function similarizeCopiesCreationAndLastModificationDateTimes() + { + $creationDateTime = \DateTime::createFromFormat('Y-m-d', '2000-01-01 12:00:00'); + $lastModificationDateTime = \DateTime::createFromFormat('Y-m-d', '2002-02-02 12:00:00'); + + /** @var $sourceNode NodeData */ + $sourceNode = $this->getAccessibleMock(NodeData::class, ['addOrUpdate'], ['/foo/bar', $this->mockWorkspace]); + $this->inject($sourceNode, 'nodeTypeManager', $this->mockNodeTypeManager); + $sourceNode->_set('nodeDataRepository', $this->createMock(RepositoryInterface::class)); + $sourceNode->_set('creationDateTime', $creationDateTime); + $sourceNode->_set('lastModificationDateTime', $lastModificationDateTime); + + $this->nodeData->similarize($sourceNode); + + self::assertSame($creationDateTime, $this->nodeData->getCreationDateTime()); + self::assertSame($lastModificationDateTime, $this->nodeData->getLastModificationDateTime()); + } + /** * @test */