99use Neos \ContentRepository \Core \SharedModel \Workspace \WorkspaceName ;
1010use Neos \ContentRepositoryRegistry \ContentRepositoryRegistry ;
1111use Neos \Flow \Persistence \PersistenceManagerInterface ;
12+ use Neos \Flow \Security \Context ;
1213use Neos \Media \Domain \Model \AssetInterface ;
1314use Neos \Media \Domain \Model \AssetVariantInterface ;
1415use Neos \Neos \AssetUsage \Dto \AssetUsageFilter ;
@@ -24,6 +25,7 @@ public function __construct(
2425 protected readonly ContentRepositoryRegistry $ contentRepositoryRegistry ,
2526 protected readonly PersistenceManagerInterface $ persistenceManager ,
2627 protected readonly ContentCacheFlusher $ contentCacheFlusher ,
28+ protected readonly Context $ securityContext ,
2729 ) {
2830 }
2931
@@ -46,30 +48,32 @@ public function registerAssetChange(AssetInterface $asset): void
4648 ->groupByNodeAggregate ()
4749 ->includeVariantsOfAsset ();
4850
49- foreach ($ this ->globalAssetUsageService ->findByFilter ($ filter ) as $ contentRepositoryId => $ usages ) {
50- $ contentRepository = $ this ->contentRepositoryRegistry ->get (ContentRepositoryId::fromString ($ contentRepositoryId ));
51+ $ this ->securityContext ->withoutAuthorizationChecks (function () use ($ filter ) {
52+ foreach ($ this ->globalAssetUsageService ->findByFilter ($ filter ) as $ contentRepositoryId => $ usages ) {
53+ $ contentRepository = $ this ->contentRepositoryRegistry ->get (ContentRepositoryId::fromString ($ contentRepositoryId ));
5154
52- foreach ($ usages as $ usage ) {
53- $ workspaceNames = $ this ->getWorkspaceNameAndChildWorkspaceNames ($ contentRepository , $ usage ->workspaceName );
55+ foreach ($ usages as $ usage ) {
56+ $ workspaceNames = $ this ->getWorkspaceNameAndChildWorkspaceNames ($ contentRepository , $ usage ->workspaceName );
5457
55- foreach ($ workspaceNames as $ workspaceName ) {
56- $ contentGraph = $ contentRepository ->getContentGraph ($ workspaceName );
57- $ nodeAggregate = $ contentGraph ->findNodeAggregateById ($ usage ->nodeAggregateId );
58- if ($ nodeAggregate === null ) {
59- continue ;
60- }
61- $ flushNodeAggregateRequest = FlushNodeAggregateRequest::create (
62- $ contentRepository ->id ,
63- $ workspaceName ,
64- $ nodeAggregate ->nodeAggregateId ,
65- $ nodeAggregate ->nodeTypeName ,
66- $ contentGraph ->findAncestorNodeAggregateIds ($ nodeAggregate ->nodeAggregateId ),
67- );
58+ foreach ($ workspaceNames as $ workspaceName ) {
59+ $ contentGraph = $ contentRepository ->getContentGraph ($ workspaceName );
60+ $ nodeAggregate = $ contentGraph ->findNodeAggregateById ($ usage ->nodeAggregateId );
61+ if ($ nodeAggregate === null ) {
62+ continue ;
63+ }
64+ $ flushNodeAggregateRequest = FlushNodeAggregateRequest::create (
65+ $ contentRepository ->id ,
66+ $ workspaceName ,
67+ $ nodeAggregate ->nodeAggregateId ,
68+ $ nodeAggregate ->nodeTypeName ,
69+ $ contentGraph ->findAncestorNodeAggregateIds ($ nodeAggregate ->nodeAggregateId ),
70+ );
6871
69- $ this ->contentCacheFlusher ->flushNodeAggregate ($ flushNodeAggregateRequest , CacheFlushingStrategy::ON_SHUTDOWN );
72+ $ this ->contentCacheFlusher ->flushNodeAggregate ($ flushNodeAggregateRequest , CacheFlushingStrategy::ON_SHUTDOWN );
73+ }
7074 }
7175 }
72- }
76+ });
7377 }
7478
7579 /**
0 commit comments