29
29
use Neos \ContentRepository \Core \NodeType \NodeTypeName ;
30
30
use Neos \ContentRepository \Core \Projection \ProjectionInterface ;
31
31
use Neos \ContentRepository \Core \Projection \ProjectionStatus ;
32
- use Neos \ContentRepository \Core \Projection \WithMarkStaleInterface ;
33
32
use Neos \ContentRepository \Core \SharedModel \Node \NodeAggregateId ;
34
33
use Neos \ContentRepository \Core \SharedModel \Node \PropertyName ;
35
34
use Neos \EventStore \Model \EventEnvelope ;
41
40
* @implements ProjectionInterface<DocumentUriPathFinder>
42
41
* @internal implementation detail to manage document node uris. For resolving please use the NodeUriBuilder and for matching the Router.
43
42
*/
44
- final class DocumentUriPathProjection implements ProjectionInterface, WithMarkStaleInterface
43
+ final class DocumentUriPathProjection implements ProjectionInterface
45
44
{
46
45
public const COLUMN_TYPES_DOCUMENT_URIS = [
47
46
'shortcutTarget ' => Types::JSON ,
48
47
];
49
48
50
- private ? DocumentUriPathFinder $ stateAccessor = null ;
49
+ private DocumentUriPathFinder $ documentUriPathFinder ;
51
50
52
51
/**
53
52
* @var array<string, DocumentTypeClassification>
@@ -59,6 +58,7 @@ public function __construct(
59
58
private readonly Connection $ dbal ,
60
59
private readonly string $ tableNamePrefix ,
61
60
) {
61
+ $ this ->documentUriPathFinder = new DocumentUriPathFinder ($ this ->dbal , $ this ->tableNamePrefix );
62
62
}
63
63
64
64
public function setUp (): void
@@ -101,7 +101,6 @@ private function determineRequiredSqlStatements(): array
101
101
public function resetState (): void
102
102
{
103
103
$ this ->truncateDatabaseTables ();
104
- $ this ->stateAccessor = null ;
105
104
}
106
105
107
106
private function truncateDatabaseTables (): void
@@ -136,13 +135,7 @@ public function apply(EventInterface $event, EventEnvelope $eventEnvelope): void
136
135
137
136
public function getState (): DocumentUriPathFinder
138
137
{
139
- if (!$ this ->stateAccessor ) {
140
- $ this ->stateAccessor = new DocumentUriPathFinder ($ this ->dbal , $ this ->tableNamePrefix );
141
-
142
- // !!! Bugfix #4253: during projection replay/update, it is crucial to have caches disabled.
143
- $ this ->stateAccessor ->disableCache ();
144
- }
145
- return $ this ->stateAccessor ;
138
+ return $ this ->documentUriPathFinder ;
146
139
}
147
140
148
141
private function whenRootNodeAggregateWithNodeWasCreated (RootNodeAggregateWithNodeWasCreated $ event ): void
@@ -174,7 +167,7 @@ private function whenRootNodeAggregateDimensionsWereUpdated(RootNodeAggregateDim
174
167
// Zero-dimensional means DimensionSpacePoint::fromArray([])->hash
175
168
assert (is_string ($ anyPointHash ));
176
169
177
- $ nodeInSomeDimension = $ this ->tryGetNode (fn () => $ this ->getState () ->getByIdAndDimensionSpacePointHash (
170
+ $ nodeInSomeDimension = $ this ->tryGetNode (fn () => $ this ->documentUriPathFinder ->getByIdAndDimensionSpacePointHash (
178
171
$ event ->nodeAggregateId ,
179
172
$ anyPointHash
180
173
));
@@ -223,7 +216,7 @@ private function whenNodeAggregateWithNodeWasCreated(NodeAggregateWithNodeWasCre
223
216
}
224
217
225
218
foreach ($ event ->succeedingSiblingsForCoverage ->toDimensionSpacePointSet () as $ dimensionSpacePoint ) {
226
- $ parentNode = $ this ->tryGetNode (fn () => $ this ->getState () ->getByIdAndDimensionSpacePointHash (
219
+ $ parentNode = $ this ->tryGetNode (fn () => $ this ->documentUriPathFinder ->getByIdAndDimensionSpacePointHash (
227
220
$ event ->parentNodeAggregateId ,
228
221
$ dimensionSpacePoint ->hash
229
222
));
@@ -236,7 +229,7 @@ private function whenNodeAggregateWithNodeWasCreated(NodeAggregateWithNodeWasCre
236
229
237
230
$ succeedingSiblingNodeAggregateId = $ event ->succeedingSiblingsForCoverage ->getSucceedingSiblingIdForDimensionSpacePoint ($ dimensionSpacePoint );
238
231
if ($ succeedingSiblingNodeAggregateId === null ) {
239
- $ precedingNode = $ this ->tryGetNode (fn () => $ this ->getState () ->getLastChildNode (
232
+ $ precedingNode = $ this ->tryGetNode (fn () => $ this ->documentUriPathFinder ->getLastChildNode (
240
233
$ parentNode ->getNodeAggregateId (),
241
234
$ dimensionSpacePoint ->hash
242
235
));
@@ -248,7 +241,7 @@ private function whenNodeAggregateWithNodeWasCreated(NodeAggregateWithNodeWasCre
248
241
]);
249
242
}
250
243
} else {
251
- $ precedingNode = $ this ->tryGetNode (fn () => $ this ->getState () ->getPrecedingNode (
244
+ $ precedingNode = $ this ->tryGetNode (fn () => $ this ->documentUriPathFinder ->getPrecedingNode (
252
245
$ succeedingSiblingNodeAggregateId ,
253
246
$ parentNode ->getNodeAggregateId (),
254
247
$ dimensionSpacePoint ->hash
@@ -377,7 +370,7 @@ private function copyVariants(
377
370
OriginDimensionSpacePoint $ targetOrigin ,
378
371
InterdimensionalSiblings $ interdimensionalSiblings ,
379
372
): void {
380
- $ sourceNode = $ this ->tryGetNode (fn () => $ this ->getState () ->getByIdAndDimensionSpacePointHash (
373
+ $ sourceNode = $ this ->tryGetNode (fn () => $ this ->documentUriPathFinder ->getByIdAndDimensionSpacePointHash (
381
374
$ nodeAggregateId ,
382
375
$ sourceOrigin ->hash
383
376
));
@@ -397,7 +390,7 @@ private function copyVariants(
397
390
398
391
// check the parent in the "target" dimensionSpacePoint for the "URI prefix",
399
392
// may be different, see neos/neos-development-collection#5090
400
- $ parentNode = $ this ->tryGetNode (fn () => $ this ->getState () ->getByIdAndDimensionSpacePointHash (
393
+ $ parentNode = $ this ->tryGetNode (fn () => $ this ->documentUriPathFinder ->getByIdAndDimensionSpacePointHash (
401
394
$ sourceNode ->getParentNodeAggregateId (),
402
395
$ interdimensionalSibling ->dimensionSpacePoint ->hash
403
396
));
@@ -422,7 +415,7 @@ private function whenSubtreeWasTagged(SubtreeWasTagged $event): void
422
415
return ;
423
416
}
424
417
foreach ($ event ->affectedDimensionSpacePoints as $ dimensionSpacePoint ) {
425
- $ node = $ this ->tryGetNode (fn () => $ this ->getState () ->getByIdAndDimensionSpacePointHash (
418
+ $ node = $ this ->tryGetNode (fn () => $ this ->documentUriPathFinder ->getByIdAndDimensionSpacePointHash (
426
419
$ event ->nodeAggregateId ,
427
420
$ dimensionSpacePoint ->hash
428
421
));
@@ -451,7 +444,7 @@ private function whenSubtreeWasUntagged(SubtreeWasUntagged $event): void
451
444
}
452
445
453
446
foreach ($ event ->affectedDimensionSpacePoints as $ dimensionSpacePoint ) {
454
- $ node = $ this ->tryGetNode (fn () => $ this ->getState () ->getByIdAndDimensionSpacePointHash (
447
+ $ node = $ this ->tryGetNode (fn () => $ this ->documentUriPathFinder ->getByIdAndDimensionSpacePointHash (
455
448
$ event ->nodeAggregateId ,
456
449
$ dimensionSpacePoint ->hash
457
450
));
@@ -479,7 +472,7 @@ private function whenNodeAggregateWasRemoved(NodeAggregateWasRemoved $event): vo
479
472
return ;
480
473
}
481
474
foreach ($ event ->affectedCoveredDimensionSpacePoints as $ dimensionSpacePoint ) {
482
- $ node = $ this ->tryGetNode (fn () => $ this ->getState () ->getByIdAndDimensionSpacePointHash (
475
+ $ node = $ this ->tryGetNode (fn () => $ this ->documentUriPathFinder ->getByIdAndDimensionSpacePointHash (
483
476
$ event ->nodeAggregateId ,
484
477
$ dimensionSpacePoint ->hash
485
478
));
@@ -499,7 +492,6 @@ private function whenNodeAggregateWasRemoved(NodeAggregateWasRemoved $event): vo
499
492
'nodeAggregateId ' => $ node ->getNodeAggregateId ()->value ,
500
493
'childNodeAggregateIdPathPrefix ' => $ node ->getNodeAggregateIdPath () . '/% ' ,
501
494
]);
502
- $ this ->getState ()->purgeCacheFor ($ node );
503
495
}
504
496
}
505
497
@@ -520,7 +512,7 @@ private function whenNodePropertiesWereSet(NodePropertiesWereSet $event): void
520
512
}
521
513
522
514
foreach ($ event ->affectedDimensionSpacePoints as $ affectedDimensionSpacePoint ) {
523
- $ node = $ this ->tryGetNode (fn () => $ this ->getState () ->getByIdAndDimensionSpacePointHash (
515
+ $ node = $ this ->tryGetNode (fn () => $ this ->documentUriPathFinder ->getByIdAndDimensionSpacePointHash (
524
516
$ event ->nodeAggregateId ,
525
517
$ affectedDimensionSpacePoint ->hash
526
518
));
@@ -570,7 +562,6 @@ private function whenNodePropertiesWereSet(NodePropertiesWereSet $event): void
570
562
'childNodeAggregateIdPathPrefix ' => $ node ->getNodeAggregateIdPath () . '/% ' ,
571
563
]
572
564
);
573
- $ this ->getState ()->purgeCacheFor ($ node );
574
565
}
575
566
}
576
567
@@ -581,7 +572,7 @@ private function whenNodeAggregateWasMoved(NodeAggregateWasMoved $event): void
581
572
}
582
573
583
574
foreach ($ event ->succeedingSiblingsForCoverage as $ succeedingSiblingForCoverage ) {
584
- $ node = $ this ->tryGetNode (fn () => $ this ->getState () ->getByIdAndDimensionSpacePointHash (
575
+ $ node = $ this ->tryGetNode (fn () => $ this ->documentUriPathFinder ->getByIdAndDimensionSpacePointHash (
585
576
$ event ->nodeAggregateId ,
586
577
$ succeedingSiblingForCoverage ->dimensionSpacePoint ->hash
587
578
));
@@ -595,8 +586,6 @@ private function whenNodeAggregateWasMoved(NodeAggregateWasMoved $event): void
595
586
$ event ->newParentNodeAggregateId ,
596
587
$ succeedingSiblingForCoverage ->nodeAggregateId
597
588
);
598
-
599
- $ this ->getState ()->purgeCacheFor ($ node );
600
589
}
601
590
}
602
591
@@ -612,7 +601,7 @@ private function moveNode(
612
601
if (!$ newParentNodeAggregateId || $ newParentNodeAggregateId ->equals ($ node ->getParentNodeAggregateId ())) {
613
602
return ;
614
603
}
615
- $ newParentNode = $ this ->tryGetNode (fn () => $ this ->getState () ->getByIdAndDimensionSpacePointHash (
604
+ $ newParentNode = $ this ->tryGetNode (fn () => $ this ->documentUriPathFinder ->getByIdAndDimensionSpacePointHash (
616
605
$ newParentNodeAggregateId ,
617
606
$ node ->getDimensionSpacePointHash ()
618
607
));
@@ -622,7 +611,7 @@ private function moveNode(
622
611
return ;
623
612
}
624
613
625
- $ oldParentNode = $ this ->tryGetNode (fn () => $ this ->getState () ->getByIdAndDimensionSpacePointHash (
614
+ $ oldParentNode = $ this ->tryGetNode (fn () => $ this ->documentUriPathFinder ->getByIdAndDimensionSpacePointHash (
626
615
$ node ->getParentNodeAggregateId (),
627
616
$ node ->getDimensionSpacePointHash ()
628
617
));
@@ -868,7 +857,7 @@ private function connectNodeWithSiblings(
868
857
?NodeAggregateId $ newSucceedingNodeAggregateId ,
869
858
): void {
870
859
if ($ newSucceedingNodeAggregateId !== null ) {
871
- $ newPrecedingNode = $ this ->tryGetNode (fn () => $ this ->getState () ->getPrecedingNode (
860
+ $ newPrecedingNode = $ this ->tryGetNode (fn () => $ this ->documentUriPathFinder ->getPrecedingNode (
872
861
$ newSucceedingNodeAggregateId ,
873
862
$ parentNodeAggregateId ,
874
863
$ node ->getDimensionSpacePointHash ()
@@ -881,7 +870,7 @@ private function connectNodeWithSiblings(
881
870
['precedingNodeAggregateId ' => $ node ->getNodeAggregateId ()->value ]
882
871
);
883
872
} else {
884
- $ newPrecedingNode = $ this ->tryGetNode (fn () => $ this ->getState () ->getLastChildNodeNotBeing (
873
+ $ newPrecedingNode = $ this ->tryGetNode (fn () => $ this ->documentUriPathFinder ->getLastChildNodeNotBeing (
885
874
$ parentNodeAggregateId ,
886
875
$ node ->getDimensionSpacePointHash (),
887
876
$ node ->getNodeAggregateId ()
@@ -985,9 +974,4 @@ private function whenDimensionShineThroughWasAdded(DimensionShineThroughWasAdded
985
974
}
986
975
}
987
976
}
988
-
989
- public function markStale (): void
990
- {
991
- $ this ->getState ()->disableCache ();
992
- }
993
977
}
0 commit comments