Skip to content

Commit f779ef2

Browse files
authored
Magento Auto Sync Merge from: magento / magento2ce / develop
2 parents d60c55b + ed9edb1 commit f779ef2

File tree

27 files changed

+392
-57
lines changed

27 files changed

+392
-57
lines changed

PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<!--- Provide a description of the changes proposed in the pull request -->
55

66
### Fixed Issues (if relevant)
7-
<!--- Provide a list of fixed issues in the format magento/magetno2#<issue_number>, if relevant -->
8-
1. magento/magetno2#<issue_number>: Issue title
7+
<!--- Provide a list of fixed issues in the format magento/magento2#<issue_number>, if relevant -->
8+
1. magento/magento2#<issue_number>: Issue title
99
2. ...
1010

1111
### Manual testing scenarios

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ public function getQuality()
292292
*/
293293
public function setKeepAspectRatio($keep)
294294
{
295-
$this->_keepAspectRatio = (bool)$keep;
295+
$this->_keepAspectRatio = $keep && $keep !== 'false';
296296
return $this;
297297
}
298298

@@ -302,7 +302,7 @@ public function setKeepAspectRatio($keep)
302302
*/
303303
public function setKeepFrame($keep)
304304
{
305-
$this->_keepFrame = (bool)$keep;
305+
$this->_keepFrame = $keep && $keep !== 'false';
306306
return $this;
307307
}
308308

@@ -312,7 +312,7 @@ public function setKeepFrame($keep)
312312
*/
313313
public function setKeepTransparency($keep)
314314
{
315-
$this->_keepTransparency = (bool)$keep;
315+
$this->_keepTransparency = $keep && $keep !== 'false';
316316
return $this;
317317
}
318318

@@ -322,7 +322,7 @@ public function setKeepTransparency($keep)
322322
*/
323323
public function setConstrainOnly($flag)
324324
{
325-
$this->_constrainOnly = (bool)$flag;
325+
$this->_constrainOnly = $flag && $flag !== 'false';
326326
return $this;
327327
}
328328

app/code/Magento/Catalog/Model/ResourceModel/Category.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ public function getChildrenCategories($category)
744744
)->setOrder(
745745
'position',
746746
\Magento\Framework\DB\Select::SQL_ASC
747-
)->joinUrlRewrite()->load();
747+
)->joinUrlRewrite();
748748

749749
return $collection;
750750
}

app/code/Magento/CatalogInventory/Helper/Stock.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ public function __construct(
8282
public function assignStatusToProduct(Product $product, $status = null)
8383
{
8484
if ($status === null) {
85-
$websiteId = $this->getStockConfiguration()->getDefaultScopeId();
86-
$stockStatus = $this->stockRegistryProvider->getStockStatus($product->getId(), $websiteId);
85+
$scopeId = $this->getStockConfiguration()->getDefaultScopeId();
86+
$stockStatus = $this->stockRegistryProvider->getStockStatus($product->getId(), $scopeId);
8787
$status = $stockStatus->getStockStatus();
8888
}
8989
$product->setIsSalable($status);
@@ -98,10 +98,10 @@ public function assignStatusToProduct(Product $product, $status = null)
9898
*/
9999
public function addStockStatusToProducts(AbstractCollection $productCollection)
100100
{
101-
$websiteId = $this->getStockConfiguration()->getDefaultScopeId();
101+
$scopeId = $this->getStockConfiguration()->getDefaultScopeId();
102102
foreach ($productCollection as $product) {
103103
$productId = $product->getId();
104-
$stockStatus = $this->stockRegistryProvider->getStockStatus($productId, $websiteId);
104+
$stockStatus = $this->stockRegistryProvider->getStockStatus($productId, $scopeId);
105105
$status = $stockStatus->getStockStatus();
106106
$product->setIsSalable($status);
107107
}

app/code/Magento/Checkout/Block/Cart/Item/Renderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ public function getProductOptions()
268268
}
269269

270270
/**
271-
* Get list of all otions for product
271+
* Get list of all options for product
272272
*
273273
* @return array
274274
* @codeCoverageIgnore

app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ public function execute()
243243
$isSubscribed = $this->getRequest()->getPost('subscription');
244244
}
245245
if ($isSubscribed !== null) {
246-
if ($isSubscribed !== 'false') {
246+
if ($isSubscribed !== '0') {
247247
$this->_subscriberFactory->create()->subscribeCustomerById($customerId);
248248
} else {
249249
$this->_subscriberFactory->create()->unsubscribeCustomerById($customerId);

app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/SaveTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ public function testExecuteWithNewCustomer()
610610
{
611611
$customerId = 22;
612612
$addressId = 11;
613-
$subscription = 'false';
613+
$subscription = '0';
614614
$postValue = [
615615
'customer' => [
616616
'coolness' => false,
@@ -875,7 +875,7 @@ public function testExecuteWithNewCustomer()
875875
*/
876876
public function testExecuteWithNewCustomerAndValidationException()
877877
{
878-
$subscription = 'false';
878+
$subscription = '0';
879879
$postValue = [
880880
'customer' => [
881881
'coolness' => false,
@@ -1018,7 +1018,7 @@ public function testExecuteWithNewCustomerAndValidationException()
10181018
*/
10191019
public function testExecuteWithNewCustomerAndLocalizedException()
10201020
{
1021-
$subscription = 'false';
1021+
$subscription = '0';
10221022
$postValue = [
10231023
'customer' => [
10241024
'coolness' => false,
@@ -1161,7 +1161,7 @@ public function testExecuteWithNewCustomerAndLocalizedException()
11611161
*/
11621162
public function testExecuteWithNewCustomerAndException()
11631163
{
1164-
$subscription = 'false';
1164+
$subscription = '0';
11651165
$postValue = [
11661166
'customer' => [
11671167
'coolness' => false,

app/code/Magento/Downloadable/Observer/SetLinkStatusObserver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
8383
if ($item->getProductType() == \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE
8484
|| $item->getRealProductType() == \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE
8585
) {
86-
if (in_array($item->getStatusId(), $expiredStatuses)) {
86+
if ($order->isCanceled() || in_array($item->getStatusId(), $expiredStatuses)) {
8787
$downloadableItemsStatuses[$item->getId()] = $linkStatuses['expired'];
8888
} else {
8989
$downloadableItemsStatuses[$item->getId()] = $linkStatuses['avail'];

app/code/Magento/PageCache/Controller/Block.php

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,44 @@
77
*/
88
namespace Magento\PageCache\Controller;
99

10+
use Magento\Framework\Serialize\Serializer\Base64Json;
11+
use Magento\Framework\Serialize\Serializer\Json;
12+
1013
abstract class Block extends \Magento\Framework\App\Action\Action
1114
{
1215
/**
1316
* @var \Magento\Framework\Translate\InlineInterface
1417
*/
1518
protected $translateInline;
1619

20+
/**
21+
* @var Json
22+
*/
23+
private $jsonSerializer;
24+
25+
/**
26+
* @var Base64Json
27+
*/
28+
private $base64jsonSerializer;
29+
1730
/**
1831
* @param \Magento\Framework\App\Action\Context $context
1932
* @param \Magento\Framework\Translate\InlineInterface $translateInline
33+
* @param Json $jsonSerializer
34+
* @param Base64Json $base64jsonSerializer
2035
*/
2136
public function __construct(
2237
\Magento\Framework\App\Action\Context $context,
23-
\Magento\Framework\Translate\InlineInterface $translateInline
38+
\Magento\Framework\Translate\InlineInterface $translateInline,
39+
Json $jsonSerializer = null,
40+
Base64Json $base64jsonSerializer = null
2441
) {
2542
parent::__construct($context);
2643
$this->translateInline = $translateInline;
44+
$this->jsonSerializer = $jsonSerializer
45+
?: \Magento\Framework\App\ObjectManager::getInstance()->get(Json::class);
46+
$this->base64jsonSerializer = $base64jsonSerializer
47+
?: \Magento\Framework\App\ObjectManager::getInstance()->get(Base64Json::class);
2748
}
2849

2950
/**
@@ -39,8 +60,8 @@ protected function _getBlocks()
3960
if (!$handles || !$blocks) {
4061
return [];
4162
}
42-
$blocks = json_decode($blocks);
43-
$handles = json_decode($handles);
63+
$blocks = $this->jsonSerializer->unserialize($blocks);
64+
$handles = $this->base64jsonSerializer->unserialize($handles);
4465

4566
$this->_view->loadLayout($handles, true, true, false);
4667
$data = [];

app/code/Magento/PageCache/Observer/ProcessLayoutRenderElement.php

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
use Magento\Framework\Event\ObserverInterface;
1010
use Magento\Framework\View\EntitySpecificHandlesList;
11+
use Magento\Framework\Serialize\Serializer\Json;
12+
use Magento\Framework\Serialize\Serializer\Base64Json;
1113

1214
class ProcessLayoutRenderElement implements ObserverInterface
1315
{
@@ -37,19 +39,37 @@ class ProcessLayoutRenderElement implements ObserverInterface
3739
*/
3840
private $entitySpecificHandlesList;
3941

42+
/**
43+
* @var Base64Json
44+
*/
45+
private $base64jsonSerializer;
46+
47+
/**
48+
* @var Json
49+
*/
50+
private $jsonSerializer;
51+
4052
/**
4153
* Class constructor
4254
*
4355
* @param \Magento\PageCache\Model\Config $config
4456
* @param EntitySpecificHandlesList $entitySpecificHandlesList
57+
* @param Json $jsonSerializer
58+
* @param Base64Json $base64jsonSerializer
4559
*/
4660
public function __construct(
4761
\Magento\PageCache\Model\Config $config,
48-
EntitySpecificHandlesList $entitySpecificHandlesList = null
62+
EntitySpecificHandlesList $entitySpecificHandlesList = null,
63+
Json $jsonSerializer = null,
64+
Base64Json $base64jsonSerializer = null
4965
) {
5066
$this->_config = $config;
5167
$this->entitySpecificHandlesList = $entitySpecificHandlesList
5268
?: \Magento\Framework\App\ObjectManager::getInstance()->get(EntitySpecificHandlesList::class);
69+
$this->jsonSerializer = $jsonSerializer
70+
?: \Magento\Framework\App\ObjectManager::getInstance()->get(Json::class);
71+
$this->base64jsonSerializer = $base64jsonSerializer
72+
?: \Magento\Framework\App\ObjectManager::getInstance()->get(Base64Json::class);
5373
}
5474

5575
/**
@@ -68,8 +88,10 @@ private function _wrapEsi(
6888
$url = $block->getUrl(
6989
'page_cache/block/esi',
7090
[
71-
'blocks' => json_encode([$block->getNameInLayout()]),
72-
'handles' => json_encode(array_values(array_diff($handles, $pageSpecificHandles)))
91+
'blocks' => $this->jsonSerializer->serialize([$block->getNameInLayout()]),
92+
'handles' => $this->base64jsonSerializer->serialize(
93+
array_values(array_diff($handles, $pageSpecificHandles))
94+
)
7395
]
7496
);
7597
// Varnish does not support ESI over HTTPS must change to HTTP

app/code/Magento/PageCache/Test/Unit/Controller/Block/EsiTest.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
namespace Magento\PageCache\Test\Unit\Controller\Block;
1111

12+
/**
13+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
14+
*/
1215
class EsiTest extends \PHPUnit_Framework_TestCase
1316
{
1417
/**
@@ -69,7 +72,12 @@ protected function setUp()
6972
$helperObjectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
7073
$this->action = $helperObjectManager->getObject(
7174
\Magento\PageCache\Controller\Block\Esi::class,
72-
['context' => $contextMock, 'translateInline' => $this->translateInline]
75+
[
76+
'context' => $contextMock,
77+
'translateInline' => $this->translateInline,
78+
'jsonSerializer' => new \Magento\Framework\Serialize\Serializer\Json(),
79+
'base64jsonSerializer' => new \Magento\Framework\Serialize\Serializer\Base64Json()
80+
]
7381
);
7482
}
7583

@@ -83,7 +91,7 @@ public function testExecute($blockClass, $shouldSetHeaders)
8391
$block = 'block';
8492
$handles = ['handle1', 'handle2'];
8593
$html = 'some-html';
86-
$mapData = [['blocks', '', json_encode([$block])], ['handles', '', json_encode($handles)]];
94+
$mapData = [['blocks', '', json_encode([$block])], ['handles', '', base64_encode(json_encode($handles))]];
8795

8896
$blockInstance1 = $this->getMock(
8997
$blockClass,

app/code/Magento/PageCache/Test/Unit/Controller/Block/RenderTest.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
namespace Magento\PageCache\Test\Unit\Controller\Block;
1111

12+
/**
13+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
14+
*/
1215
class RenderTest extends \PHPUnit_Framework_TestCase
1316
{
1417
/**
@@ -71,7 +74,12 @@ protected function setUp()
7174
$helperObjectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
7275
$this->action = $helperObjectManager->getObject(
7376
\Magento\PageCache\Controller\Block\Render::class,
74-
['context' => $contextMock, 'translateInline' => $this->translateInline]
77+
[
78+
'context' => $contextMock,
79+
'translateInline' => $this->translateInline,
80+
'jsonSerializer' => new \Magento\Framework\Serialize\Serializer\Json(),
81+
'base64jsonSerializer' => new \Magento\Framework\Serialize\Serializer\Base64Json()
82+
]
7583
);
7684
}
7785

@@ -151,7 +159,7 @@ public function testExecute()
151159
$this->requestMock->expects($this->at(11))
152160
->method('getParam')
153161
->with($this->equalTo('handles'), $this->equalTo(''))
154-
->will($this->returnValue(json_encode($handles)));
162+
->will($this->returnValue(base64_encode(json_encode($handles))));
155163
$this->viewMock->expects($this->once())->method('loadLayout')->with($this->equalTo($handles));
156164
$this->viewMock->expects($this->any())->method('getLayout')->will($this->returnValue($this->layoutMock));
157165
$this->layoutMock->expects($this->at(0))

0 commit comments

Comments
 (0)