Skip to content

Commit 631e111

Browse files
author
Hayder Sharhan
committed
MAGETWO-50551: When saving product or category cache cleared by general tag
- Code cleanup.
1 parent 46db9d8 commit 631e111

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

app/code/Magento/CacheInvalidate/Observer/InvalidateVarnishObserver.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ public function execute(\Magento\Framework\Event\Observer $observer)
5050
foreach ($object->getIdentities() as $tag) {
5151
$tags[] = sprintf($pattern, $tag);
5252
}
53-
$this->purgeCache->sendPurgeRequest(implode('|', array_unique($tags)));
53+
if (!empty($tags)) {
54+
$this->purgeCache->sendPurgeRequest(implode('|', array_unique($tags)));
55+
}
5456
}
5557
}
5658
}

app/code/Magento/Catalog/Model/Product.php

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2268,7 +2268,7 @@ public function getIdentities()
22682268
$identities[] = self::CACHE_PRODUCT_CATEGORY_TAG . '_' . $categoryId;
22692269
}
22702270
}
2271-
if ($this->getAppState()->getAreaCode() === 'frontend') {
2271+
if ($this->getAppState()->getAreaCode() === \Magento\Framework\App\Area::AREA_FRONTEND) {
22722272
$identities[] = self::CACHE_TAG;
22732273
}
22742274
return array_unique($identities);
@@ -2560,27 +2560,16 @@ public function setId($value)
25602560
/**
25612561
* Get application state
25622562
*
2563+
* @deprecated
25632564
* @return \Magento\Framework\App\State
25642565
*/
25652566
private function getAppState()
25662567
{
25672568
if (!$this->appState instanceof \Magento\Framework\App\State) {
2568-
return \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\Framework\App\State');
2569-
} else {
2570-
return $this->appState;
2569+
$this->appState = \Magento\Framework\App\ObjectManager::getInstance()->get(
2570+
\Magento\Framework\App\State::class
2571+
);
25712572
}
2572-
}
2573-
2574-
/**
2575-
* Set application state
2576-
*
2577-
* @deprecated
2578-
* @param \Magento\Framework\App\State $appState
2579-
* @return $this
2580-
*/
2581-
public function setAppState(\Magento\Framework\App\State $appState)
2582-
{
2583-
$this->appState = $appState;
2584-
return $this;
2573+
return $this->appState;
25852574
}
25862575
}

0 commit comments

Comments
 (0)