Skip to content

Commit 4bb5ea8

Browse files
authored
EZP-28326: Use improved signals with parent id's to clear relevant cache (#39)
* EZP-28326: Use improved signals with parent id's to clear relevant cache Makes it possible to now expire parent location as well as sibling cache for affected content. Depends on ezsystems/ezpublish-kernel#2169 * Added tests
1 parent 436fdc6 commit 4bb5ea8

File tree

6 files changed

+48
-17
lines changed

6 files changed

+48
-17
lines changed

src/SignalSlot/MoveSubtreeSlot.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ class MoveSubtreeSlot extends AbstractContentSlot
2020
*/
2121
protected function generateTags(Signal $signal)
2222
{
23-
// @todo Missing info to clear sibling and parent cache of old parent!
2423
return [
2524
'path-' . $signal->locationId,
25+
'location-' . $signal->oldParentLocationId,
26+
'parent-' . $signal->oldParentLocationId,
2627
'location-' . $signal->newParentLocationId,
2728
'parent-' . $signal->newParentLocationId,
2829
];

src/SignalSlot/SwapLocationSlot.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@ class SwapLocationSlot extends AbstractContentSlot
2121
protected function generateTags(Signal $signal)
2222
{
2323
return [
24-
'location-' . $signal->location1Id,
25-
'parent-' . $signal->location1Id,
26-
'location-' . $signal->location2Id,
27-
'parent-' . $signal->location2Id,
24+
'content-' . $signal->content1Id,
25+
'path-' . $signal->location1Id,
26+
'location-' . $signal->parentLocation1Id,
27+
'parent-' . $signal->parentLocation1Id,
28+
'content-' . $signal->content2Id,
29+
'path-' . $signal->location2Id,
30+
'location-' . $signal->parentLocation2Id,
31+
'parent-' . $signal->parentLocation2Id,
2832
];
2933
}
3034

src/SignalSlot/UpdateLocationSlot.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313
/**
1414
* A slot handling UpdateLocationSignal.
15-
*
16-
* @todo Signal missing info on parent location, which is relevant if priority of location was updated.
1715
*/
1816
class UpdateLocationSlot extends AbstractContentSlot
1917
{

tests/SignalSlot/CreateLocationSlotTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@
1212

1313
class CreateLocationSlotTest extends AbstractContentSlotTest
1414
{
15+
protected $locationId = 45;
16+
protected $parentLocationId = 43;
17+
1518
public function createSignal()
1619
{
17-
return new CreateLocationSignal(['contentId' => $this->contentId]);
20+
return new CreateLocationSignal(['contentId' => $this->contentId, 'locationId' => $this->locationId, 'parentLocationId' => $this->parentLocationId]);
1821
}
1922

2023
public function getSlotClass()
@@ -24,6 +27,6 @@ public function getSlotClass()
2427

2528
public function getReceivedSignalClasses()
2629
{
27-
return ['eZ\Publish\Core\SignalSlot\Signal\LocationService\CreateLocationSignal'];
30+
return [CreateLocationSignal::class];
2831
}
2932
}

tests/SignalSlot/MoveSubtreeSlotTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,22 @@ class MoveSubtreeSlotTest extends AbstractContentSlotTest
1414
{
1515
protected $locationId = 45;
1616
protected $parentLocationId = 43;
17+
protected $oldParentLocationId = 2;
1718

1819
public function createSignal()
1920
{
2021
return new MoveSubtreeSignal(
2122
[
2223
'locationId' => $this->locationId,
2324
'newParentLocationId' => $this->parentLocationId,
25+
'oldParentLocationId' => $this->oldParentLocationId,
2426
]
2527
);
2628
}
2729

2830
public function generateTags()
2931
{
30-
return ['path-' . $this->locationId, 'location-' . $this->parentLocationId, 'parent-' . $this->parentLocationId];
32+
return ['path-' . $this->locationId, 'location-' . $this->oldParentLocationId, 'parent-' . $this->oldParentLocationId, 'location-' . $this->parentLocationId, 'parent-' . $this->parentLocationId];
3133
}
3234

3335
public function getSlotClass()
@@ -37,6 +39,6 @@ public function getSlotClass()
3739

3840
public function getReceivedSignalClasses()
3941
{
40-
return ['eZ\Publish\Core\SignalSlot\Signal\LocationService\MoveSubtreeSignal'];
42+
return [MoveSubtreeSignal::class];
4143
}
4244
}

tests/SignalSlot/SwapLocationSlotTest.php

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,46 @@
1212

1313
class SwapLocationSlotTest extends AbstractContentSlotTest
1414
{
15-
public function setUp()
15+
protected $locationId = 45;
16+
protected $parentLocationId = 43;
17+
18+
protected $swapContentId = 62;
19+
protected $swapLocationId = 65;
20+
protected $swapParentLocationId = 63;
21+
22+
public function createSignal()
1623
{
17-
$this->markTestIncomplete('fixme');
24+
return new SwapLocationSignal([
25+
'content1Id' => $this->contentId,
26+
'location1Id' => $this->locationId,
27+
'parentLocation1Id' => $this->parentLocationId,
28+
'content2Id' => $this->swapContentId,
29+
'location2Id' => $this->swapLocationId,
30+
'parentLocation2Id' => $this->swapParentLocationId,
31+
]);
1832
}
1933

20-
public function createSignal()
34+
public function generateTags()
2135
{
22-
return new SwapLocationSignal(['content1Id' => $this->contentId]);
36+
return [
37+
'content-' . $this->contentId,
38+
'path-' . $this->locationId,
39+
'location-' . $this->parentLocationId,
40+
'parent-' . $this->parentLocationId,
41+
'content-' . $this->swapContentId,
42+
'path-' . $this->swapLocationId,
43+
'location-' . $this->swapParentLocationId,
44+
'parent-' . $this->swapParentLocationId,
45+
];
2346
}
2447

2548
public function getSlotClass()
2649
{
27-
return 'EzSystems\PlatformHttpCacheBundle\SignalSlot\SetContentStateSlot';
50+
return 'EzSystems\PlatformHttpCacheBundle\SignalSlot\SwapLocationSlot';
2851
}
2952

3053
public function getReceivedSignalClasses()
3154
{
32-
return ['eZ\Publish\Core\SignalSlot\Signal\ObjectStateService\SetContentStateSignal'];
55+
return [SwapLocationSignal::class];
3356
}
3457
}

0 commit comments

Comments
 (0)