Skip to content
Snippets Groups Projects
Commit 41e98f6d authored by Ján Forgáč's avatar Ján Forgáč
Browse files

NetteCacheInvalidator: remove duplicate cache keys to clean + CacheSubscriber:...

NetteCacheInvalidator: remove duplicate cache keys to clean + CacheSubscriber: prevent array_too_deep error
parent 1a392c07
No related branches found
Tags v4.8.9
No related merge requests found
Pipeline #36147 failed with stage
in 1 minute and 12 seconds
......@@ -47,7 +47,7 @@ class CacheSubscriber implements Common\EventSubscriber
$changed = false;
foreach ($changeSet as $change) {
if ($change[0] != $change[1]) {
if (!is_scalar($change[0]) || !is_scalar($change[1]) || $change[0] != $change[1]) {
$changed = true;
}
}
......
......@@ -19,6 +19,8 @@ class NetteCacheInvalidator implements CacheInvalidator
/** @var array[] */
private $queue = [];
private $queuedTags = [];
public function __construct(NCaching\IStorage $storage)
{
$this->storage = $storage;
......@@ -26,9 +28,20 @@ class NetteCacheInvalidator implements CacheInvalidator
public function queue(Cacheable $cacheable)
{
$this->queue[] = [
NCaching\Cache::TAGS => $cacheable->getCacheTags(),
];
$newTags = $cacheable->getCacheTags();
foreach ($newTags as $key => $tag) {
if (isset($this->queuedTags[$tag])) {
unset($newTags[$key]);
} else {
$this->queuedTags[$tag] = $tag;
}
}
if ($newTags) {
$this->queue[] = [
NCaching\Cache::TAGS => array_values($newTags),
];
}
}
public function flush()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment