File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,11 @@ public function execute(\Magento\Framework\Event\Observer $observer): void
8181 continue ;
8282 }
8383 $ tag = $ this ->cacheTags ->convertCacheTags ($ tag );
84+
85+ if (!$ this ->isTagAllowed ($ tag )) {
86+ continue ;
87+ }
88+
8489 if (!in_array ($ tag , $ this ->alreadyPurged )) {
8590 $ tags [] = $ tag ;
8691 $ this ->alreadyPurged [] = $ tag ;
@@ -113,4 +118,24 @@ private function canPurgeObject(\Magento\Framework\DataObject\IdentityInterface
113118 }
114119 return true ;
115120 }
121+
122+ /**
123+ * Additional validation since IdentityInterface can pass canPurgeObject check (e.g. ProductRuleIndexer), but still
124+ * hold tags of products or categories
125+ *
126+ * @param string $tag
127+ * @return bool
128+ */
129+ private function isTagAllowed (string $ tag )
130+ {
131+ if ($ tag === \Magento \Catalog \Model \Category::CACHE_TAG && !$ this ->config ->canPurgeCatalogCategory ()) {
132+ return false ;
133+ }
134+
135+ if ($ tag === \Magento \Catalog \Model \Product::CACHE_TAG && !$ this ->config ->canPurgeCatalogProduct ()) {
136+ return false ;
137+ }
138+
139+ return true ;
140+ }
116141}
You can’t perform that action at this time.
0 commit comments