Skip to content

Commit 194f687

Browse files
author
Igor Melnikov
committed
Merge branch 'upstream-develop' into MAGETWO-51068-admin-session
2 parents 1ffb236 + 73fb299 commit 194f687

File tree

246 files changed

+5532
-2780
lines changed

Some content is hidden

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

246 files changed

+5532
-2780
lines changed

app/code/Magento/Backend/view/adminhtml/templates/admin/login.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
value=""
2828
data-validate="{required:true}"
2929
placeholder="<?php /* @escapeNotVerified */ echo __('user name') ?>"
30-
autocomplete="username"
30+
autocomplete="off"
3131
/>
3232
</div>
3333
</div>
@@ -43,7 +43,7 @@
4343
data-validate="{required:true}"
4444
value=""
4545
placeholder="<?php /* @escapeNotVerified */ echo __('password') ?>"
46-
autocomplete="current-password"
46+
autocomplete="off"
4747
/>
4848
</div>
4949
</div>

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/Controller/Adminhtml/Product/Save.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
use Magento\Backend\App\Action;
1010
use Magento\Catalog\Controller\Adminhtml\Product;
1111
use Magento\Store\Model\StoreManagerInterface;
12+
use Magento\Framework\App\Request\DataPersistorInterface;
1213

14+
/**
15+
* Class Save
16+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
17+
*/
1318
class Save extends \Magento\Catalog\Controller\Adminhtml\Product
1419
{
1520
/**
@@ -37,6 +42,11 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Product
3742
*/
3843
protected $productRepository;
3944

45+
/**
46+
* @var DataPersistorInterface
47+
*/
48+
protected $dataPersistor;
49+
4050
/**
4151
* @var StoreManagerInterface
4252
*/
@@ -110,6 +120,7 @@ public function execute()
110120
$this->copyToStores($data, $productId);
111121

112122
$this->messageManager->addSuccess(__('You saved the product.'));
123+
$this->getDataPersistor()->clear('catalog_product');
113124
if ($product->getSku() != $originalSku) {
114125
$this->messageManager->addNotice(
115126
__(
@@ -131,11 +142,13 @@ public function execute()
131142
} catch (\Magento\Framework\Exception\LocalizedException $e) {
132143
$this->messageManager->addError($e->getMessage());
133144
$this->_session->setProductData($data);
145+
$this->getDataPersistor()->set('catalog_product', $data);
134146
$redirectBack = $productId ? true : 'new';
135147
} catch (\Exception $e) {
136148
$this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e);
137149
$this->messageManager->addError($e->getMessage());
138150
$this->_session->setProductData($data);
151+
$this->getDataPersistor()->set('catalog_product', $data);
139152
$redirectBack = $productId ? true : 'new';
140153
}
141154
} else {
@@ -246,4 +259,18 @@ private function getStoreManager()
246259
}
247260
return $this->storeManager;
248261
}
262+
263+
/**
264+
* Retrieve data persistor
265+
*
266+
* @return DataPersistorInterface|mixed
267+
*/
268+
protected function getDataPersistor()
269+
{
270+
if (null === $this->dataPersistor) {
271+
$this->dataPersistor = $this->_objectManager->get(DataPersistorInterface::class);
272+
}
273+
274+
return $this->dataPersistor;
275+
}
249276
}

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,32 @@ public function process(\DOMElement $mediaNode, $mediaParentTag)
3030
if ($attribute->nodeType != XML_ELEMENT_NODE) {
3131
continue;
3232
}
33-
$nodeValue = $attribute->nodeValue;
33+
if ($attribute->tagName == 'background') {
34+
$nodeValue = $this->processImageBackground($attribute->nodeValue);
35+
} else {
36+
$nodeValue = $attribute->nodeValue;
37+
}
3438
$result[$mediaParentTag][$moduleNameImage][Image::MEDIA_TYPE_CONFIG_NODE][$imageId][$attribute->tagName]
3539
= $nodeValue;
3640
}
3741
}
3842

3943
return $result;
4044
}
45+
46+
/**
47+
* Convert rgb background string into array
48+
*
49+
* @param string $backgroundString
50+
* @return int[]
51+
*/
52+
private function processImageBackground($backgroundString)
53+
{
54+
$pattern = '#\[(\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\]#';
55+
$backgroundArray = [];
56+
if (preg_match($pattern, $backgroundString, $backgroundArray)) {
57+
array_shift($backgroundArray);
58+
}
59+
return $backgroundArray;
60+
}
4161
}

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
}

0 commit comments

Comments
 (0)