diff --git a/Neos.ContentRepository/Classes/Domain/Service/PublishingService.php b/Neos.ContentRepository/Classes/Domain/Service/PublishingService.php index 7e94b871b9c..0c352dea3df 100644 --- a/Neos.ContentRepository/Classes/Domain/Service/PublishingService.php +++ b/Neos.ContentRepository/Classes/Domain/Service/PublishingService.php @@ -182,8 +182,11 @@ protected function doDiscardNode(NodeInterface $node, array &$alreadyDiscardedNo if ($possibleShadowNodeData instanceof NodeData) { if ($possibleShadowNodeData->getMovedTo() !== null) { $parentBasePath = $node->getPath(); - $affectedChildNodeDataInSameWorkspace = $this->nodeDataRepository->findByParentAndNodeType($parentBasePath, null, $node->getWorkspace(), null, false, true); - foreach ($affectedChildNodeDataInSameWorkspace as $affectedChildNodeData) { + $affectedChildNodeDataInWorkspaceChain = $this->nodeDataRepository->findByParentAndNodeType($parentBasePath, null, $node->getWorkspace(), null, false, true); + foreach ($affectedChildNodeDataInWorkspaceChain as $affectedChildNodeData) { + if (!$affectedChildNodeData->matchesWorkspaceAndDimensions($node->getWorkspace(), $node->getDimensions())) { + continue; + } /** @var NodeData $affectedChildNodeData */ $affectedChildNode = $this->nodeFactory->createFromNodeData($affectedChildNodeData, $node->getContext()); $this->doDiscardNode($affectedChildNode, $alreadyDiscardedNodeIdentifiers); diff --git a/Neos.Media/Classes/Domain/Model/Thumbnail.php b/Neos.Media/Classes/Domain/Model/Thumbnail.php index bbc5ed5552c..56d3cf87c82 100644 --- a/Neos.Media/Classes/Domain/Model/Thumbnail.php +++ b/Neos.Media/Classes/Domain/Model/Thumbnail.php @@ -224,4 +224,9 @@ public function refresh() { $this->generatorStrategy->refresh($this); } + + public function getConfigurationHash(): string + { + return $this->configurationHash; + } } diff --git a/Neos.Media/Classes/Domain/Service/ThumbnailGenerator.php b/Neos.Media/Classes/Domain/Service/ThumbnailGenerator.php index bb817fa8a3e..b9ded1f0f43 100644 --- a/Neos.Media/Classes/Domain/Service/ThumbnailGenerator.php +++ b/Neos.Media/Classes/Domain/Service/ThumbnailGenerator.php @@ -48,8 +48,10 @@ public function createThumbnails(AssetInterface $image) { if ($this->autoCreateThumbnailPresets) { foreach ($this->thumbnailService->getPresets() as $preset => $presetConfiguration) { - $thumbnailConfiguration = $this->thumbnailService->getThumbnailConfigurationForPreset($preset, $this->asyncThumbnails); - $this->thumbnailService->getThumbnail($image, $thumbnailConfiguration); + if ($presetConfiguration) { + $thumbnailConfiguration = $this->thumbnailService->getThumbnailConfigurationForPreset($preset, $this->asyncThumbnails); + $this->thumbnailService->getThumbnail($image, $thumbnailConfiguration); + } } } } diff --git a/Neos.Media/Classes/Domain/Service/ThumbnailService.php b/Neos.Media/Classes/Domain/Service/ThumbnailService.php index 4efc5544fd4..32843c971c3 100644 --- a/Neos.Media/Classes/Domain/Service/ThumbnailService.php +++ b/Neos.Media/Classes/Domain/Service/ThumbnailService.php @@ -132,8 +132,16 @@ public function getThumbnail(AssetInterface $asset, ThumbnailConfiguration $conf if (isset($this->thumbnailCache[$assetIdentifier][$configurationHash])) { $thumbnail = $this->thumbnailCache[$assetIdentifier][$configurationHash]; } else { - $thumbnail = $this->thumbnailRepository->findOneByAssetAndThumbnailConfiguration($asset, $configuration); - $this->thumbnailCache[$assetIdentifier][$configurationHash] = $thumbnail; + $thumbnail = null; + // Load all thumbnails for the asset and cache them to prevent further db requests for the same asset + $thumbnailsForAsset = $this->thumbnailRepository->findByOriginalAsset($asset); + /** @var Thumbnail $thumbnailVariant */ + foreach ($thumbnailsForAsset as $thumbnailVariant) { + $this->thumbnailCache[$assetIdentifier][$thumbnailVariant->getConfigurationHash()] = $thumbnailVariant; + if ($thumbnailVariant->getConfigurationHash() === $configurationHash) { + $thumbnail = $thumbnailVariant; + } + } } $async = $configuration->isAsync(); if ($thumbnail === null) {