Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Observer/InvalidateVarnishObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ public function execute(\Magento\Framework\Event\Observer $observer): void
continue;
}
$tag = $this->cacheTags->convertCacheTags($tag);

if (!$this->isTagAllowed($tag)) {
continue;
}

if (!in_array($tag, $this->alreadyPurged)) {
$tags[] = $tag;
$this->alreadyPurged[] = $tag;
Expand Down Expand Up @@ -113,4 +118,24 @@ private function canPurgeObject(\Magento\Framework\DataObject\IdentityInterface
}
return true;
}

/**
* Additional validation since IdentityInterface can pass canPurgeObject check (e.g. ProductRuleIndexer), but still
* hold tags of products or categories
*
* @param string $tag
* @return bool
*/
private function isTagAllowed(string $tag)
{
if ($tag === \Magento\Catalog\Model\Category::CACHE_TAG && !$this->config->canPurgeCatalogCategory()) {
return false;
}

if ($tag === \Magento\Catalog\Model\Product::CACHE_TAG && !$this->config->canPurgeCatalogProduct()) {
return false;
}

return true;
}
}
Loading