Skip to content

Commit 6e8bd8f

Browse files
Merge pull request #56 from nlx-lars/bugfix/contentcacheflusher-aspect
BUGFIX: Use ContentCacheFlusher Aspect for banning varnish pages
2 parents b431dbb + fd4aee0 commit 6e8bd8f

3 files changed

Lines changed: 31 additions & 30 deletions

File tree

Classes/Aspects/ContentCacheAspect.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
namespace MOC\Varnish\Aspects;
55

6+
use MOC\Varnish\Service\CacheTagService;
7+
use MOC\Varnish\Service\VarnishBanService;
68
use Neos\Flow\Annotations as Flow;
79
use Neos\Flow\Aop\JoinPointInterface;
810
use Neos\Flow\Configuration\Exception\InvalidConfigurationException;
@@ -30,6 +32,18 @@ class ContentCacheAspect
3032
*/
3133
protected $logger;
3234

35+
/**
36+
* @Flow\Inject
37+
* @var VarnishBanService
38+
*/
39+
protected $varnishBanService;
40+
41+
/**
42+
* @Flow\Inject
43+
* @var CacheTagService
44+
*/
45+
protected $cacheTagService;
46+
3347
/**
3448
* @var bool
3549
*/
@@ -106,6 +120,21 @@ public function registerDisableContentCache(JoinPointInterface $joinPoint): void
106120
}
107121
}
108122

123+
/**
124+
* @Flow\Before("setting(MOC.Varnish.enabled) && method(Neos\Neos\Fusion\Cache\ContentCacheFlusher->shutdownObject())")
125+
* @param JoinPointInterface $joinPoint
126+
*
127+
* @throws PropertyNotAccessibleException
128+
*/
129+
public function interceptContentCacheFlush(JoinPointInterface $joinPoint)
130+
{
131+
$object = $joinPoint->getProxy();
132+
133+
$tags = array_keys(ObjectAccess::getProperty($object, 'tagsToFlush', true));
134+
135+
$this->varnishBanService->banByTags($tags);
136+
}
137+
109138
/**
110139
* @return bool true if an uncached segment was evaluated
111140
*/

Classes/Package.php

Lines changed: 0 additions & 30 deletions
This file was deleted.

Classes/Service/ContentCacheFlusherService.php

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

2020
/**
2121
* @Flow\Scope("singleton")
22+
*
23+
* @deprecated will be removed with 6.0
2224
*/
2325
class ContentCacheFlusherService
2426
{

0 commit comments

Comments
 (0)