Skip to content

Commit 388be5d

Browse files
committed
ACP2E-3063: [Cloud] Cache is not getting invalidated.
- without test
1 parent 25d2e42 commit 388be5d

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

app/code/Magento/Cms/Observer/InvalidateLayoutCacheObserver.php

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@
1818

1919
namespace Magento\Cms\Observer;
2020

21-
use Magento\Catalog\Model\Product;
2221
use Magento\Cms\Model\Page;
2322
use Magento\Framework\App\Cache\Type\Layout as LayoutCache;
2423
use Magento\Framework\App\Cache\StateInterface as CacheState;
2524
use Magento\Framework\App\Cache\Tag\Resolver;
2625
use Magento\Framework\Event\Observer;
2726
use Magento\Framework\Event\ObserverInterface;
28-
use Magento\Widget\Model\Widget\Instance;
27+
use Magento\Framework\Model\AbstractModel;
2928

3029
/**
3130
* Invalidates layout cache.
@@ -81,7 +80,7 @@ public function execute(Observer $observer)
8180
return;
8281
}
8382

84-
if (!$object->dataHasChangedFor(Page::PAGE_LAYOUT)) {
83+
if (!$object instanceof Page || !$object->dataHasChangedFor(Page::PAGE_LAYOUT)) {
8584
return;
8685
}
8786

@@ -95,25 +94,19 @@ public function execute(Observer $observer)
9594

9695
/**
9796
* Get additional tags
97+
*
98+
* @param AbstractModel $object
99+
* @return string
98100
*/
99-
public function getAdditionalTags($object): string
101+
public function getAdditionalTags(AbstractModel $object): string
100102
{
101103
$tag = '';
102104
if ($object instanceof Page) {
103105
$tag = sprintf(
104-
'%s_%s',
105-
'CMS_PAGE_VIEW_ID',
106-
str_replace('-', '_', strtoupper($object->getIdentifier()))
107-
);
108-
} elseif ($object instanceof Product) {
109-
$tag = sprintf(
110-
'%s',
111-
str_replace(
112-
'{{ID}}',
113-
(string) $object->getId(),
114-
Instance::SINGLE_PRODUCT_LAYOUT_HANDLE
115-
),
116-
);
106+
'%s_%s',
107+
'CMS_PAGE_VIEW_ID',
108+
str_replace('-', '_', strtoupper($object->getIdentifier()))
109+
);
117110
}
118111
return $tag;
119112
}

0 commit comments

Comments
 (0)