Skip to content

Commit 355751e

Browse files
Merge branch 'develop' of https://github.corp.magento.com/magento2/magento2ce into MAGETWO-51470
2 parents 1499153 + 73fb299 commit 355751e

File tree

72 files changed

+1409
-752
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1409
-752
lines changed

app/code/Magento/CacheInvalidate/etc/events.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,7 @@
4848
<event name="controller_action_postdispatch_adminhtml_system_currencysymbol_save">
4949
<observer name="flush_varnish_pagecache" instance="Magento\CacheInvalidate\Observer\InvalidateVarnishObserver"/>
5050
</event>
51+
<event name="clean_cache_after_reindex">
52+
<observer name="flush_varnish_pagecache" instance="Magento\CacheInvalidate\Observer\InvalidateVarnishObserver"/>
53+
</event>
5154
</config>

app/code/Magento/Catalog/Model/Indexer/Category/AffectCache.php

Lines changed: 0 additions & 39 deletions
This file was deleted.

app/code/Magento/Catalog/Model/Indexer/Category/Flat.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Catalog\Model\Indexer\Category;
77

8+
use Magento\Framework\Indexer\CacheContext;
9+
810
class Flat implements \Magento\Framework\Indexer\ActionInterface, \Magento\Framework\Mview\ActionInterface
911
{
1012
/**
@@ -17,9 +19,16 @@ class Flat implements \Magento\Framework\Indexer\ActionInterface, \Magento\Frame
1719
*/
1820
protected $rowsActionFactory;
1921

20-
/** @var \Magento\Framework\Indexer\IndexerRegistry */
22+
/**
23+
* @var \Magento\Framework\Indexer\IndexerRegistry
24+
*/
2125
protected $indexerRegistry;
2226

27+
/**
28+
* @var \Magento\Framework\Indexer\CacheContext
29+
*/
30+
private $cacheContext;
31+
2332
/**
2433
* @param Flat\Action\FullFactory $fullActionFactory
2534
* @param Flat\Action\RowsFactory $rowsActionFactory
@@ -54,6 +63,7 @@ public function execute($ids)
5463
$action->reindex($ids, true);
5564
}
5665
$action->reindex($ids);
66+
$this->getCacheContext()->registerEntities(\Magento\Catalog\Model\Category::CACHE_TAG, $ids);
5767
}
5868

5969
/**
@@ -64,6 +74,7 @@ public function execute($ids)
6474
public function executeFull()
6575
{
6676
$this->fullActionFactory->create()->reindexAll();
77+
$this->getCacheContext()->registerTags([\Magento\Catalog\Model\Category::CACHE_TAG]);
6778
}
6879

6980
/**
@@ -87,4 +98,19 @@ public function executeRow($id)
8798
{
8899
$this->execute([$id]);
89100
}
101+
102+
/**
103+
* Get cache context
104+
*
105+
* @return \Magento\Framework\Indexer\CacheContext
106+
* @deprecated
107+
*/
108+
protected function getCacheContext()
109+
{
110+
if (!($this->cacheContext instanceof CacheContext)) {
111+
return \Magento\Framework\App\ObjectManager::getInstance()->get(CacheContext::class);
112+
} else {
113+
return $this->cacheContext;
114+
}
115+
}
90116
}

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

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Catalog\Model\Indexer\Category;
77

8+
use Magento\Framework\Indexer\CacheContext;
9+
810
class Product implements \Magento\Framework\Indexer\ActionInterface, \Magento\Framework\Mview\ActionInterface
911
{
1012
/**
@@ -22,9 +24,16 @@ class Product implements \Magento\Framework\Indexer\ActionInterface, \Magento\Fr
2224
*/
2325
protected $rowsActionFactory;
2426

25-
/** @var \Magento\Framework\Indexer\IndexerRegistry */
27+
/**
28+
* @var \Magento\Framework\Indexer\IndexerRegistry
29+
*/
2630
protected $indexerRegistry;
2731

32+
/**
33+
* @var \Magento\Framework\Indexer\CacheContext
34+
*/
35+
protected $cacheContext;
36+
2837
/**
2938
* @param Product\Action\FullFactory $fullActionFactory
3039
* @param Product\Action\RowsFactory $rowsActionFactory
@@ -49,6 +58,18 @@ public function __construct(
4958
public function execute($ids)
5059
{
5160
$this->executeAction($ids);
61+
$this->registerEntities($ids);
62+
}
63+
64+
/**
65+
* Add entities to cache context
66+
*
67+
* @param int[] $ids
68+
* @return void
69+
*/
70+
protected function registerEntities($ids)
71+
{
72+
$this->getCacheContext()->registerEntities(\Magento\Catalog\Model\Category::CACHE_TAG, $ids);
5273
}
5374

5475
/**
@@ -59,6 +80,17 @@ public function execute($ids)
5980
public function executeFull()
6081
{
6182
$this->fullActionFactory->create()->execute();
83+
$this->registerTags();
84+
}
85+
86+
/**
87+
* Add tags to cache context
88+
*
89+
* @return void
90+
*/
91+
protected function registerTags()
92+
{
93+
$this->getCacheContext()->registerTags([\Magento\Catalog\Model\Category::CACHE_TAG]);
6294
}
6395

6496
/**
@@ -103,4 +135,19 @@ protected function executeAction($ids)
103135

104136
return $this;
105137
}
138+
139+
/**
140+
* Get cache context
141+
*
142+
* @return \Magento\Framework\Indexer\CacheContext
143+
* @deprecated
144+
*/
145+
protected function getCacheContext()
146+
{
147+
if (!($this->cacheContext instanceof CacheContext)) {
148+
return \Magento\Framework\App\ObjectManager::getInstance()->get(CacheContext::class);
149+
} else {
150+
return $this->cacheContext;
151+
}
152+
}
106153
}

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

Lines changed: 0 additions & 39 deletions
This file was deleted.

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,30 @@ public function __construct(
2424
) {
2525
parent::__construct($fullActionFactory, $rowsActionFactory, $indexerRegistry);
2626
}
27+
28+
/**
29+
* Add tags to cache context
30+
*
31+
* @return void
32+
*/
33+
protected function registerTags()
34+
{
35+
$this->getCacheContext()->registerTags(
36+
[
37+
\Magento\Catalog\Model\Category::CACHE_TAG,
38+
\Magento\Catalog\Model\Product::CACHE_TAG
39+
]
40+
);
41+
}
42+
43+
/**
44+
* Add entities to cache context
45+
*
46+
* @param int[] $ids
47+
* @return void
48+
*/
49+
protected function registerEntities($ids)
50+
{
51+
$this->getCacheContext()->registerEntities(\Magento\Catalog\Model\Product::CACHE_TAG, $ids);
52+
}
2753
}

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Catalog\Model\Indexer\Product;
77

8+
use Magento\Framework\Indexer\CacheContext;
9+
810
class Eav implements \Magento\Framework\Indexer\ActionInterface, \Magento\Framework\Mview\ActionInterface
911
{
1012
/**
@@ -22,6 +24,11 @@ class Eav implements \Magento\Framework\Indexer\ActionInterface, \Magento\Framew
2224
*/
2325
protected $_productEavIndexerFull;
2426

27+
/**
28+
* @var \Magento\Framework\Indexer\CacheContext
29+
*/
30+
private $cacheContext;
31+
2532
/**
2633
* @param Eav\Action\Row $productEavIndexerRow
2734
* @param Eav\Action\Rows $productEavIndexerRows
@@ -46,6 +53,7 @@ public function __construct(
4653
public function execute($ids)
4754
{
4855
$this->_productEavIndexerRows->execute($ids);
56+
$this->getCacheContext()->registerEntities(\Magento\Catalog\Model\Product::CACHE_TAG, $ids);
4957
}
5058

5159
/**
@@ -56,6 +64,12 @@ public function execute($ids)
5664
public function executeFull()
5765
{
5866
$this->_productEavIndexerFull->execute();
67+
$this->getCacheContext()->registerTags(
68+
[
69+
\Magento\Catalog\Model\Category::CACHE_TAG,
70+
\Magento\Catalog\Model\Product::CACHE_TAG
71+
]
72+
);
5973
}
6074

6175
/**
@@ -79,4 +93,19 @@ public function executeRow($id)
7993
{
8094
$this->_productEavIndexerRow->execute($id);
8195
}
96+
97+
/**
98+
* Get cache context
99+
*
100+
* @return \Magento\Framework\Indexer\CacheContext
101+
* @deprecated
102+
*/
103+
protected function getCacheContext()
104+
{
105+
if (!($this->cacheContext instanceof CacheContext)) {
106+
return \Magento\Framework\App\ObjectManager::getInstance()->get(CacheContext::class);
107+
} else {
108+
return $this->cacheContext;
109+
}
110+
}
82111
}

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Catalog\Model\Indexer\Product;
77

8+
use Magento\Framework\Indexer\CacheContext;
9+
810
class Flat implements \Magento\Framework\Indexer\ActionInterface, \Magento\Framework\Mview\ActionInterface
911
{
1012
/**
@@ -22,6 +24,11 @@ class Flat implements \Magento\Framework\Indexer\ActionInterface, \Magento\Frame
2224
*/
2325
protected $_productFlatIndexerFull;
2426

27+
/**
28+
* @var \Magento\Framework\Indexer\CacheContext
29+
*/
30+
private $cacheContext;
31+
2532
/**
2633
* @param Flat\Action\Row $productFlatIndexerRow
2734
* @param Flat\Action\Rows $productFlatIndexerRows
@@ -46,6 +53,7 @@ public function __construct(
4653
public function execute($ids)
4754
{
4855
$this->_productFlatIndexerRows->execute($ids);
56+
$this->getCacheContext()->registerEntities(\Magento\Catalog\Model\Product::CACHE_TAG, $ids);
4957
}
5058

5159
/**
@@ -56,6 +64,12 @@ public function execute($ids)
5664
public function executeFull()
5765
{
5866
$this->_productFlatIndexerFull->execute();
67+
$this->getCacheContext()->registerTags(
68+
[
69+
\Magento\Catalog\Model\Category::CACHE_TAG,
70+
\Magento\Catalog\Model\Product::CACHE_TAG
71+
]
72+
);
5973
}
6074

6175
/**
@@ -79,4 +93,19 @@ public function executeRow($id)
7993
{
8094
$this->_productFlatIndexerRow->execute($id);
8195
}
96+
97+
/**
98+
* Get cache context
99+
*
100+
* @return \Magento\Framework\Indexer\CacheContext
101+
* @deprecated
102+
*/
103+
protected function getCacheContext()
104+
{
105+
if (!($this->cacheContext instanceof CacheContext)) {
106+
return \Magento\Framework\App\ObjectManager::getInstance()->get(CacheContext::class);
107+
} else {
108+
return $this->cacheContext;
109+
}
110+
}
82111
}

0 commit comments

Comments
 (0)