Skip to content

Commit

Permalink
BUGFIX: Force direct access on setting node properties in node data s…
Browse files Browse the repository at this point in the history
…imilarize
  • Loading branch information
dlubitz committed Oct 9, 2024
1 parent 3da7961 commit 04763af
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Neos.ContentRepository/Classes/Domain/Model/NodeData.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
21 changes: 21 additions & 0 deletions Neos.ContentRepository/Tests/Unit/Domain/Model/NodeDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit 04763af

Please sign in to comment.