Skip to content

Commit b0aabd7

Browse files
committed
BUGFIX: Enable storing rendered documents in non public workspaces
1 parent eb2bca8 commit b0aabd7

4 files changed

Lines changed: 18 additions & 12 deletions

File tree

Classes/Aspects/CacheUrlMappingAspect.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,6 @@ public function storeRootCacheIdentifier(JoinPointInterface $joinPoint)
102102

103103
/** @var NodeInterface $node */
104104
$node = $this->currentEvaluateContext['cacheIdentifierValues']['node'];
105-
if (!$node->getContext()->getWorkspace()->isPublicWorkspace()) {
106-
return;
107-
}
108105

109106
$url = $this->getCurrentUrl();
110107

@@ -144,6 +141,7 @@ public function storeRootCacheIdentifier(JoinPointInterface $joinPoint)
144141
$logger->debug('Mapping URL ' . $url . ' to ' . $rootIdentifier . ' with tags ' . implode(', ', $rootTags));
145142

146143
$arguments = $this->getCurrentArguments($node);
144+
// TODO: To make parallel rendering possible, we need to make sure that the cache key also includes the currently rendered workspace, as the node might originate from a base workspace (usually live). See `DocumentNodeCacheKey`.
147145
$rootKey = DocumentNodeCacheKey::fromNodeAndArguments($node, $arguments);
148146
$rootCacheValues = DocumentNodeCacheValues::create($rootIdentifier, $url);
149147
// allow other document metadata generators here

Classes/NodeEnumeration/Domain/Dto/EnumeratedNode.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,14 @@ static public function fromJsonString(string $enumeratedNodeString): self
5656
return new self($tmp['contextPath'], $tmp['nodeIdentifier'], $tmp['arguments']);
5757
}
5858

59-
public function jsonSerialize()
59+
public function jsonSerialize(): array
6060
{
6161
return [
6262
'contextPath' => $this->contextPath,
6363
'nodeIdentifier' => $this->nodeIdentifier,
64-
'arguments' => $this->arguments
64+
'dimensions' => $this->getDimensionsFromContextPath(),
65+
'workspaceName' => $this->getWorkspaceNameFromContextPath(),
66+
'arguments' => $this->arguments,
6567
];
6668
}
6769

@@ -86,9 +88,6 @@ public function getWorkspaceNameFromContextPath(): string
8688
return $nodePathAndContext['workspaceName'];
8789
}
8890

89-
/**
90-
* @return string
91-
*/
9291
public function getNodeIdentifier(): string
9392
{
9493
return $this->nodeIdentifier;

Classes/NodeRendering/Dto/DocumentNodeCacheKey.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,35 +25,42 @@ final class DocumentNodeCacheKey
2525
*/
2626
protected $dimensions;
2727

28+
/**
29+
* @var string
30+
*/
31+
protected $workspaceName;
32+
2833
/**
2934
* @var array
3035
*/
3136
protected $arguments;
3237

33-
private function __construct(string $nodeIdentifier, array $dimensions, array $arguments)
38+
private function __construct(string $nodeIdentifier, array $dimensions, string $workspaceName, array $arguments)
3439
{
3540
// we need to make this deterministic
3641
ksort($arguments);
3742
ksort($dimensions);
3843

3944
$this->nodeIdentifier = $nodeIdentifier;
4045
$this->dimensions = $dimensions;
46+
$this->workspaceName = $workspaceName;
4147
$this->arguments = $arguments;
4248
}
4349

4450

4551
public static function fromNodeAndArguments(NodeInterface $node, array $arguments): self
4652
{
47-
return new self($node->getIdentifier(), $node->getContext()->getDimensions(), $arguments);
53+
return new self($node->getIdentifier(), $node->getContext()->getDimensions(), $node->getWorkspace()->getName(), $arguments);
4854
}
4955

5056
public static function fromEnumeratedNode(EnumeratedNode $enumeratedNode)
5157
{
52-
return new self($enumeratedNode->getNodeIdentifier(), $enumeratedNode->getDimensionsFromContextPath(), $enumeratedNode->getArguments());
58+
return new self($enumeratedNode->getNodeIdentifier(), $enumeratedNode->getDimensionsFromContextPath(), $enumeratedNode->getWorkspaceNameFromContextPath(), $enumeratedNode->getArguments());
5359
}
5460

5561
public function redisKeyName(): string
5662
{
63+
// TODO: Add workspace name to cache entry to allow parallel releases, but `CacheUrlMappingAspect` has to provide node in correct workspace during rendering
5764
return preg_replace('/[^a-zA-Z0-9-]/', '_', sprintf('doc--%s-%s-%s', $this->nodeIdentifier, json_encode($this->dimensions), json_encode($this->arguments)));
5865
}
5966

Classes/NodeRendering/NodeRenderer.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ protected function renderDocumentNodeVariant(EnumeratedNode $enumeratedNode, Con
203203
$contentReleaseLogger->debug('Rendering document node variant', [
204204
'node' => $node->getContextPath(),
205205
'nodeIdentifier' => $node->getIdentifier(),
206-
'arguments' => $enumeratedNode->getArguments()
206+
'workspaceName' => $enumeratedNode->getWorkspaceNameFromContextPath(),
207+
'dimensions' => $enumeratedNode->getDimensionsFromContextPath(),
208+
'arguments' => $enumeratedNode->getArguments(),
207209
]);
208210

209211
$this->documentRenderer->renderDocumentNodeVariant($node, $enumeratedNode->getArguments(), $contentReleaseLogger);

0 commit comments

Comments
 (0)