Skip to content

Commit

Permalink
EZP-28326: Use improved signals with parent id's to clear relevant ca…
Browse files Browse the repository at this point in the history
…che (#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
  • Loading branch information
andrerom authored Nov 28, 2017
1 parent 436fdc6 commit 4bb5ea8
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 17 deletions.
3 changes: 2 additions & 1 deletion src/SignalSlot/MoveSubtreeSlot.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ class MoveSubtreeSlot extends AbstractContentSlot
*/
protected function generateTags(Signal $signal)
{
// @todo Missing info to clear sibling and parent cache of old parent!
return [
'path-' . $signal->locationId,
'location-' . $signal->oldParentLocationId,
'parent-' . $signal->oldParentLocationId,
'location-' . $signal->newParentLocationId,
'parent-' . $signal->newParentLocationId,
];
Expand Down
12 changes: 8 additions & 4 deletions src/SignalSlot/SwapLocationSlot.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ class SwapLocationSlot extends AbstractContentSlot
protected function generateTags(Signal $signal)
{
return [
'location-' . $signal->location1Id,
'parent-' . $signal->location1Id,
'location-' . $signal->location2Id,
'parent-' . $signal->location2Id,
'content-' . $signal->content1Id,
'path-' . $signal->location1Id,
'location-' . $signal->parentLocation1Id,
'parent-' . $signal->parentLocation1Id,
'content-' . $signal->content2Id,
'path-' . $signal->location2Id,
'location-' . $signal->parentLocation2Id,
'parent-' . $signal->parentLocation2Id,
];
}

Expand Down
2 changes: 0 additions & 2 deletions src/SignalSlot/UpdateLocationSlot.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

/**
* A slot handling UpdateLocationSignal.
*
* @todo Signal missing info on parent location, which is relevant if priority of location was updated.
*/
class UpdateLocationSlot extends AbstractContentSlot
{
Expand Down
7 changes: 5 additions & 2 deletions tests/SignalSlot/CreateLocationSlotTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@

class CreateLocationSlotTest extends AbstractContentSlotTest
{
protected $locationId = 45;
protected $parentLocationId = 43;

public function createSignal()
{
return new CreateLocationSignal(['contentId' => $this->contentId]);
return new CreateLocationSignal(['contentId' => $this->contentId, 'locationId' => $this->locationId, 'parentLocationId' => $this->parentLocationId]);
}

public function getSlotClass()
Expand All @@ -24,6 +27,6 @@ public function getSlotClass()

public function getReceivedSignalClasses()
{
return ['eZ\Publish\Core\SignalSlot\Signal\LocationService\CreateLocationSignal'];
return [CreateLocationSignal::class];
}
}
6 changes: 4 additions & 2 deletions tests/SignalSlot/MoveSubtreeSlotTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,22 @@ class MoveSubtreeSlotTest extends AbstractContentSlotTest
{
protected $locationId = 45;
protected $parentLocationId = 43;
protected $oldParentLocationId = 2;

public function createSignal()
{
return new MoveSubtreeSignal(
[
'locationId' => $this->locationId,
'newParentLocationId' => $this->parentLocationId,
'oldParentLocationId' => $this->oldParentLocationId,
]
);
}

public function generateTags()
{
return ['path-' . $this->locationId, 'location-' . $this->parentLocationId, 'parent-' . $this->parentLocationId];
return ['path-' . $this->locationId, 'location-' . $this->oldParentLocationId, 'parent-' . $this->oldParentLocationId, 'location-' . $this->parentLocationId, 'parent-' . $this->parentLocationId];
}

public function getSlotClass()
Expand All @@ -37,6 +39,6 @@ public function getSlotClass()

public function getReceivedSignalClasses()
{
return ['eZ\Publish\Core\SignalSlot\Signal\LocationService\MoveSubtreeSignal'];
return [MoveSubtreeSignal::class];
}
}
35 changes: 29 additions & 6 deletions tests/SignalSlot/SwapLocationSlotTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,46 @@

class SwapLocationSlotTest extends AbstractContentSlotTest
{
public function setUp()
protected $locationId = 45;
protected $parentLocationId = 43;

protected $swapContentId = 62;
protected $swapLocationId = 65;
protected $swapParentLocationId = 63;

public function createSignal()
{
$this->markTestIncomplete('fixme');
return new SwapLocationSignal([
'content1Id' => $this->contentId,
'location1Id' => $this->locationId,
'parentLocation1Id' => $this->parentLocationId,
'content2Id' => $this->swapContentId,
'location2Id' => $this->swapLocationId,
'parentLocation2Id' => $this->swapParentLocationId,
]);
}

public function createSignal()
public function generateTags()
{
return new SwapLocationSignal(['content1Id' => $this->contentId]);
return [
'content-' . $this->contentId,
'path-' . $this->locationId,
'location-' . $this->parentLocationId,
'parent-' . $this->parentLocationId,
'content-' . $this->swapContentId,
'path-' . $this->swapLocationId,
'location-' . $this->swapParentLocationId,
'parent-' . $this->swapParentLocationId,
];
}

public function getSlotClass()
{
return 'EzSystems\PlatformHttpCacheBundle\SignalSlot\SetContentStateSlot';
return 'EzSystems\PlatformHttpCacheBundle\SignalSlot\SwapLocationSlot';
}

public function getReceivedSignalClasses()
{
return ['eZ\Publish\Core\SignalSlot\Signal\ObjectStateService\SetContentStateSignal'];
return [SwapLocationSignal::class];
}
}

0 comments on commit 4bb5ea8

Please sign in to comment.