Skip to content

Commit bf81171

Browse files
author
Oleksandr Iegorov
authored
Merge pull request #12 from magento/develop
Merged mainline
2 parents f7ae6a2 + f553937 commit bf81171

File tree

38 files changed

+683
-74
lines changed

38 files changed

+683
-74
lines changed

app/code/Magento/AdminNotification/Block/Grid/Renderer/Notice.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ class Notice extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Abstract
1818
public function render(\Magento\Framework\DataObject $row)
1919
{
2020
return '<span class="grid-row-title">' .
21-
$row->getTitle() .
21+
$this->escapeHtml($row->getTitle()) .
2222
'</span>' .
23-
($row->getDescription() ? '<br />' .
24-
$row->getDescription() : '');
23+
($row->getDescription() ? '<br />' . $this->escapeHtml($row->getDescription()) : '');
2524
}
2625
}

app/code/Magento/Catalog/Block/Product/ListProduct.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,8 @@ public function getProductPrice(\Magento\Catalog\Model\Product $product)
363363
[
364364
'include_container' => true,
365365
'display_minimal_price' => true,
366-
'zone' => \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST
366+
'zone' => \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST,
367+
'list_category_page' => true
367368
]
368369
);
369370
}

app/code/Magento/Catalog/Model/Layer/FilterList.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ class FilterList
3030
* @var string[]
3131
*/
3232
protected $filterTypes = [
33-
self::CATEGORY_FILTER => 'Magento\Catalog\Model\Layer\Filter\Category',
34-
self::ATTRIBUTE_FILTER => 'Magento\Catalog\Model\Layer\Filter\Attribute',
35-
self::PRICE_FILTER => 'Magento\Catalog\Model\Layer\Filter\Price',
36-
self::DECIMAL_FILTER => 'Magento\Catalog\Model\Layer\Filter\Decimal',
33+
self::CATEGORY_FILTER => \Magento\Catalog\Model\Layer\Filter\Category::class,
34+
self::ATTRIBUTE_FILTER => \Magento\Catalog\Model\Layer\Filter\Attribute::class,
35+
self::PRICE_FILTER => \Magento\Catalog\Model\Layer\Filter\Price::class,
36+
self::DECIMAL_FILTER => \Magento\Catalog\Model\Layer\Filter\Decimal::class,
3737
];
3838

3939
/**

app/code/Magento/Catalog/Model/Product/Attribute/Source/Countryofmanufacture.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,11 @@ public function getAllOptions()
6363
if ($cache = $this->_configCacheType->load($cacheKey)) {
6464
$options = unserialize($cache);
6565
} else {
66-
$collection = $this->_countryFactory->create()->getResourceCollection()->loadByStore();
67-
$options = $collection->toOptionArray();
66+
/** @var \Magento\Directory\Model\Country $country */
67+
$country = $this->_countryFactory->create();
68+
/** @var \Magento\Directory\Model\ResourceModel\Country\Collection $collection */
69+
$collection = $country->getResourceCollection();
70+
$options = $collection->load()->toOptionArray();
6871
$this->_configCacheType->save(serialize($options), $cacheKey);
6972
}
7073
return $options;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,6 +1858,9 @@ protected function _productLimitationPrice($joinLeft = false)
18581858
return $this;
18591859
}
18601860

1861+
// Preventing overriding price loaded from EAV because we want to use the one from index
1862+
$this->removeAttributeToSelect('price');
1863+
18611864
$connection = $this->getConnection();
18621865
$select = $this->getSelect();
18631866
$joinCond = join(

app/code/Magento/Catalog/Pricing/Render/FinalPriceBox.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,16 @@ public function showMinimalPrice()
119119
&& $minimalPriceAValue < $finalPriceValue;
120120
}
121121

122+
/**
123+
* Get Key for caching block content
124+
*
125+
* @return string
126+
*/
127+
public function getCacheKey()
128+
{
129+
return parent::getCacheKey() . ($this->getData('list_category_page') ? '-list-category-page': '');
130+
}
131+
122132
/**
123133
* {@inheritdoc}
124134
*

app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,24 @@ protected function setUp()
8484
$cacheState = $this->getMockBuilder(\Magento\Framework\App\Cache\StateInterface::class)
8585
->getMockForAbstractClass();
8686

87-
$storeManager = $this->getMockBuilder('\Magento\Store\Model\StoreManagerInterface')
88-
->setMethods(['getStore', 'getCode'])
89-
->getMockForAbstractClass();
90-
$storeManager->expects($this->any())->method('getStore')->willReturnSelf();
91-
92-
$appState = $this->getMockBuilder('\Magento\Framework\App\State')
87+
$appState = $this->getMockBuilder(\Magento\Framework\App\State::class)
9388
->disableOriginalConstructor()
9489
->getMock();
9590

96-
$resolver = $this->getMockBuilder('\Magento\Framework\View\Element\Template\File\Resolver')
91+
$resolver = $this->getMockBuilder(\Magento\Framework\View\Element\Template\File\Resolver::class)
9792
->disableOriginalConstructor()
9893
->getMock();
9994

100-
$urlBuilder = $this->getMockBuilder('\Magento\Framework\UrlInterface')
95+
$urlBuilder = $this->getMockBuilder(\Magento\Framework\UrlInterface::class)
96+
->getMockForAbstractClass();
97+
98+
$store = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)
99+
->getMockForAbstractClass();
100+
101+
$storeManager = $this->getMockBuilder('\Magento\Store\Model\StoreManagerInterface')
102+
->setMethods(['getStore', 'getCode'])
101103
->getMockForAbstractClass();
104+
$storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store));
102105

103106
$scopeConfigMock = $this->getMockForAbstractClass('Magento\Framework\App\Config\ScopeConfigInterface');
104107
$context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false);
@@ -150,7 +153,7 @@ protected function setUp()
150153
'saleableItem' => $this->product,
151154
'rendererPool' => $this->rendererPool,
152155
'price' => $this->price,
153-
'data' => ['zone' => 'test_zone']
156+
'data' => ['zone' => 'test_zone', 'list_category_page' => true]
154157
]
155158
);
156159
}
@@ -247,6 +250,7 @@ public function testRenderAmountMinimal()
247250

248251
$arguments = [
249252
'zone' => 'test_zone',
253+
'list_category_page' => true,
250254
'display_label' => 'As low as',
251255
'price_id' => $priceId,
252256
'include_container' => false,
@@ -367,6 +371,12 @@ public function testHidePrice()
367371
$this->assertEmpty($this->object->toHtml());
368372
}
369373

374+
public function testGetCacheKey()
375+
{
376+
$result = $this->object->getCacheKey();
377+
$this->assertStringEndsWith('list-category-page', $result);
378+
}
379+
370380
public function testGetCacheKeyInfo()
371381
{
372382
$this->assertArrayHasKey('display_minimal_price', $this->object->getCacheKeyInfo());

app/code/Magento/Indexer/Model/Processor/CleanCache.php

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

8+
use \Magento\Framework\App\CacheInterface;
9+
810
class CleanCache
911
{
1012
/**
@@ -17,6 +19,11 @@ class CleanCache
1719
*/
1820
protected $eventManager;
1921

22+
/**
23+
* @var \Magento\Framework\App\CacheInterface
24+
*/
25+
private $cache;
26+
2027
/**
2128
* @param \Magento\Framework\Indexer\CacheContext $context
2229
* @param \Magento\Framework\Event\Manager $eventManager
@@ -39,6 +46,9 @@ public function __construct(
3946
public function afterUpdateMview(\Magento\Indexer\Model\Processor $subject)
4047
{
4148
$this->eventManager->dispatch('clean_cache_after_reindex', ['object' => $this->context]);
49+
if (!empty($this->context->getIdentities())) {
50+
$this->getCache()->clean($this->context->getIdentities());
51+
}
4252
}
4353

4454
/**
@@ -51,5 +61,22 @@ public function afterUpdateMview(\Magento\Indexer\Model\Processor $subject)
5161
public function afterReindexAllInvalid(\Magento\Indexer\Model\Processor $subject)
5262
{
5363
$this->eventManager->dispatch('clean_cache_by_tags', ['object' => $this->context]);
64+
if (!empty($this->context->getIdentities())) {
65+
$this->getCache()->clean($this->context->getIdentities());
66+
}
67+
}
68+
69+
/**
70+
* Get cache interface
71+
*
72+
* @return \Magento\Framework\App\CacheInterface
73+
* @deprecated
74+
*/
75+
private function getCache()
76+
{
77+
if ($this->cache === null) {
78+
$this->cache = \Magento\Framework\App\ObjectManager::getInstance()->get(CacheInterface::class);
79+
}
80+
return $this->cache;
5481
}
5582
}

app/code/Magento/Indexer/Test/Unit/Model/Processor/CleanCacheTest.php

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@
55
*/
66
namespace Magento\Indexer\Test\Unit\Model\Processor;
77

8+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
9+
use Magento\Indexer\Model\Processor\CleanCache;
10+
811
class CleanCacheTest extends \PHPUnit_Framework_TestCase
912
{
1013
/**
1114
* Tested plugin
1215
*
13-
* @var \Magento\Indexer\Model\Processor\InvalidateCache
16+
* @var \Magento\Indexer\Model\Processor\CleanCache
1417
*/
1518
protected $plugin;
1619

@@ -35,18 +38,37 @@ class CleanCacheTest extends \PHPUnit_Framework_TestCase
3538
*/
3639
protected $eventManagerMock;
3740

41+
/**
42+
* Cache mock
43+
*
44+
* @var \Magento\Framework\App\CacheInterface|\PHPUnit_Framework_MockObject_MockObject
45+
*/
46+
protected $cacheMock;
47+
48+
/**
49+
* @var ObjectManager
50+
*/
51+
protected $objectManager;
52+
3853
/**
3954
* Set up
4055
*/
4156
protected function setUp()
4257
{
58+
$this->objectManager = new ObjectManager($this);
4359
$this->subjectMock = $this->getMock('Magento\Indexer\Model\Processor', [], [], '', false);
4460
$this->contextMock = $this->getMock('Magento\Framework\Indexer\CacheContext', [], [], '', false);
4561
$this->eventManagerMock = $this->getMock('Magento\Framework\Event\Manager', [], [], '', false);
46-
$this->plugin = new \Magento\Indexer\Model\Processor\CleanCache(
62+
$this->cacheMock = $this->getMock('Magento\Framework\App\CacheInterface', [], [], '', false);
63+
$this->plugin = new CleanCache(
4764
$this->contextMock,
4865
$this->eventManagerMock
4966
);
67+
$this->objectManager->setBackwardCompatibleProperty(
68+
$this->plugin,
69+
'cache',
70+
$this->cacheMock
71+
);
5072
}
5173

5274
/**
@@ -56,12 +78,22 @@ protected function setUp()
5678
*/
5779
public function testAfterUpdateMview()
5880
{
81+
$tags = ['tag_name1', 'tag_name2'];
5982
$this->eventManagerMock->expects($this->once())
6083
->method('dispatch')
6184
->with(
6285
$this->equalTo('clean_cache_after_reindex'),
6386
$this->equalTo(['object' => $this->contextMock])
6487
);
88+
89+
$this->contextMock->expects($this->atLeastOnce())
90+
->method('getIdentities')
91+
->willReturn($tags);
92+
93+
$this->cacheMock->expects($this->once())
94+
->method('clean')
95+
->with($tags);
96+
6597
$this->plugin->afterUpdateMview($this->subjectMock);
6698
}
6799
}

app/code/Magento/Integration/etc/crontab.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">
99
<group id="default">
1010
<job name="outdated_authentication_failures_cleanup" instance="Magento\Integration\Cron\CleanExpiredAuthenticationFailures" method="execute">
11-
<schedule>0 1 * * *</schedule>
11+
<schedule>* * * * *</schedule>
1212
</job>
1313
</group>
1414
</config>

0 commit comments

Comments
 (0)