diff --git a/Neos.Neos/Classes/Fusion/Cache/AssetChangeHandlerForCacheFlushing.php b/Neos.Neos/Classes/Fusion/Cache/AssetChangeHandlerForCacheFlushing.php index 02ba6d75ea..b45efd2091 100644 --- a/Neos.Neos/Classes/Fusion/Cache/AssetChangeHandlerForCacheFlushing.php +++ b/Neos.Neos/Classes/Fusion/Cache/AssetChangeHandlerForCacheFlushing.php @@ -9,6 +9,7 @@ use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName; use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Persistence\PersistenceManagerInterface; +use Neos\Flow\Security\Context; use Neos\Media\Domain\Model\AssetInterface; use Neos\Media\Domain\Model\AssetVariantInterface; use Neos\Neos\AssetUsage\Dto\AssetUsageFilter; @@ -24,6 +25,7 @@ public function __construct( protected readonly ContentRepositoryRegistry $contentRepositoryRegistry, protected readonly PersistenceManagerInterface $persistenceManager, protected readonly ContentCacheFlusher $contentCacheFlusher, + protected readonly Context $securityContext, ) { } @@ -46,30 +48,32 @@ public function registerAssetChange(AssetInterface $asset): void ->groupByNodeAggregate() ->includeVariantsOfAsset(); - foreach ($this->globalAssetUsageService->findByFilter($filter) as $contentRepositoryId => $usages) { - $contentRepository = $this->contentRepositoryRegistry->get(ContentRepositoryId::fromString($contentRepositoryId)); + $this->securityContext->withoutAuthorizationChecks(function () use ($filter) { + foreach ($this->globalAssetUsageService->findByFilter($filter) as $contentRepositoryId => $usages) { + $contentRepository = $this->contentRepositoryRegistry->get(ContentRepositoryId::fromString($contentRepositoryId)); - foreach ($usages as $usage) { - $workspaceNames = $this->getWorkspaceNameAndChildWorkspaceNames($contentRepository, $usage->workspaceName); + foreach ($usages as $usage) { + $workspaceNames = $this->getWorkspaceNameAndChildWorkspaceNames($contentRepository, $usage->workspaceName); - foreach ($workspaceNames as $workspaceName) { - $contentGraph = $contentRepository->getContentGraph($workspaceName); - $nodeAggregate = $contentGraph->findNodeAggregateById($usage->nodeAggregateId); - if ($nodeAggregate === null) { - continue; - } - $flushNodeAggregateRequest = FlushNodeAggregateRequest::create( - $contentRepository->id, - $workspaceName, - $nodeAggregate->nodeAggregateId, - $nodeAggregate->nodeTypeName, - $contentGraph->findAncestorNodeAggregateIds($nodeAggregate->nodeAggregateId), - ); + foreach ($workspaceNames as $workspaceName) { + $contentGraph = $contentRepository->getContentGraph($workspaceName); + $nodeAggregate = $contentGraph->findNodeAggregateById($usage->nodeAggregateId); + if ($nodeAggregate === null) { + continue; + } + $flushNodeAggregateRequest = FlushNodeAggregateRequest::create( + $contentRepository->id, + $workspaceName, + $nodeAggregate->nodeAggregateId, + $nodeAggregate->nodeTypeName, + $contentGraph->findAncestorNodeAggregateIds($nodeAggregate->nodeAggregateId), + ); - $this->contentCacheFlusher->flushNodeAggregate($flushNodeAggregateRequest, CacheFlushingStrategy::ON_SHUTDOWN); + $this->contentCacheFlusher->flushNodeAggregate($flushNodeAggregateRequest, CacheFlushingStrategy::ON_SHUTDOWN); + } } } - } + }); } /**