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 11, 2024
1 parent c82b775 commit d96fbb0
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
3 changes: 1 addition & 2 deletions Neos.ContentRepository/Classes/Domain/Model/NodeData.php
Original file line number Diff line number Diff line change
Expand Up @@ -768,15 +768,14 @@ public function similarize(AbstractNodeData $sourceNode, $isCopy = false)
];
if (!$isCopy) {
$propertyNames[] = 'creationDateTime';
$propertyNames[] = 'lastModificationDateTime';
}
if ($sourceNode instanceof NodeData) {
$propertyNames[] = 'index';
$propertyNames[] = 'removed';
}

// We need to force direct access for the following properties, as they don't have a setter in AbstractNodeData
$propertyNamesToForceDirectAccess = ['creationDateTime', 'lastModificationDateTime'];
$propertyNamesToForceDirectAccess = ['creationDateTime'];
foreach ($propertyNames as $propertyName) {
ObjectAccess::setProperty(
$this,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,19 +673,16 @@ public function similarizeClearsPropertiesBeforeAddingNewOnes()
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());
}

/**
Expand Down

0 comments on commit d96fbb0

Please sign in to comment.