Skip to content

Commit

Permalink
Merge pull request #4291 from grebaldi/bugfix/ui-3184/proper-cache-in…
Browse files Browse the repository at this point in the history
…validation-on-discard

BUGFIX: Invalidate caches correctly after node move changes have been discarded
  • Loading branch information
mhsdesign committed May 14, 2024
2 parents b623608 + 21ed60f commit 4c3568a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ public function discardNode(NodeInterface $node)
*/
protected function doDiscardNode(NodeInterface $node, array &$alreadyDiscardedNodeIdentifiers = [])
{
if ($node->getWorkspace()->getBaseWorkspace() === null) {
$baseWorkspace = $node->getWorkspace()->getBaseWorkspace();
if ($baseWorkspace === null) {
throw new WorkspaceException('Nodes in a workspace without a base workspace cannot be discarded.', 1395841899);
}
if ($node->getPath() === '/') {
Expand Down Expand Up @@ -197,7 +198,7 @@ protected function doDiscardNode(NodeInterface $node, array &$alreadyDiscardedNo
}

$this->nodeDataRepository->remove($node);
$this->emitNodeDiscarded($node);
$this->emitNodeDiscarded($node, $baseWorkspace);
}

/**
Expand Down Expand Up @@ -274,11 +275,12 @@ public function emitNodePublished(NodeInterface $node, Workspace $targetWorkspac
* The signal emits the node that has been discarded.
*
* @param NodeInterface $node
* @param Workspace|null $baseWorkspace
* @return void
* @Flow\Signal
* @api
*/
public function emitNodeDiscarded(NodeInterface $node)
public function emitNodeDiscarded(NodeInterface $node, ?Workspace $baseWorkspace = null)
{
}

Expand Down
14 changes: 14 additions & 0 deletions Neos.Neos/Classes/Fusion/Cache/ContentCacheFlusher.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,20 @@ protected function addTagToFlush(string $tag, string $message = ''): void

protected function registerAllTagsToFlushForNodeInWorkspace(NodeInterface $node, Workspace $workspace): void
{
// Ensure that we're dealing with the variant of the given node that actually
// lives in the given workspace
if ($node->getWorkspace()->getName() !== $workspace->getName()) {
$workspaceContext = $this->contextFactory->create(
array_merge(
$node->getContext()->getProperties(),
['workspaceName' => $workspace->getName()]
)
);
$node = $workspaceContext->getNodeByIdentifier($node->getIdentifier());
if ($node === null) {
return;
}
}
$nodeIdentifier = $node->getIdentifier();

if (!array_key_exists($workspace->getName(), $this->workspacesToFlush) || is_array($this->workspacesToFlush[$workspace->getName()]) === false) {
Expand Down

0 comments on commit 4c3568a

Please sign in to comment.