Skip to content

Commit 13a933a

Browse files
author
Oleksii Korshenko
authored
Merge pull request #1663 from magento-engcom/2.2-develop-prs
Public Pull Requests #11959 #11898 - Change NL PostCode Pattern by @osrecio #11949 11868: "Add Products" button has been duplicated after the customer group was changed. by @nmalevanec #11917 [BACKPORT 2.2] [TASK] Add resetPassword call to the webapi by @lewisvoncken #11889 Save background color correctly in images. [backport 2.2] by @raumatbel #11869 Resolve Error While Trying To Load Quote Item Collection Using Magent… by @neeta-wagento #11858 #11697 Theme: Added html node to page xml root, cause validation error by @adrian-martinez-interactiv4 #11405 Allow setting of http response status code in a Redirection by @gabrielqs-redstage Fixed Public Issues #11898 Zip code Netherlands should allow zipcode without space #11868 "Add Products" button has been duplicated after the customer group was changed #8799 Image brackground #8954 Error While Trying To Load Quote Item Collection Using Magento\Quote\Model\ResourceModel\QuoteItem\Collection::getItems() #11697 Theme: Added html node to page xml root, cause validation error #9028 You cannot set a 303 redirect response using a result factory
2 parents fd715d7 + 88d5dfc commit 13a933a

File tree

9 files changed

+76
-29
lines changed

9 files changed

+76
-29
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
*/
66
namespace Magento\Catalog\Model;
77

8-
use Magento\Catalog\Model\Product\Attribute\Backend\Media\ImageEntryConverter;
98
use Magento\Catalog\Helper\Image;
9+
use Magento\Catalog\Model\Product\Attribute\Backend\Media\ImageEntryConverter;
10+
use Magento\Framework\View\Xsd\Media\TypeDataExtractorInterface;
1011

11-
class ImageExtractor implements \Magento\Framework\View\Xsd\Media\TypeDataExtractorInterface
12+
class ImageExtractor implements TypeDataExtractorInterface
1213
{
1314
/**
1415
* Extract configuration data of images from the DOM structure
@@ -30,8 +31,11 @@ public function process(\DOMElement $mediaNode, $mediaParentTag)
3031
if ($attribute->nodeType != XML_ELEMENT_NODE) {
3132
continue;
3233
}
33-
if ($attribute->tagName == 'background') {
34+
$attributeTagName = $attribute->tagName;
35+
if ($attributeTagName === 'background') {
3436
$nodeValue = $this->processImageBackground($attribute->nodeValue);
37+
} elseif ($attributeTagName === 'width' || $attributeTagName === 'height') {
38+
$nodeValue = intval($attribute->nodeValue);
3539
} else {
3640
$nodeValue = $attribute->nodeValue;
3741
}
@@ -55,6 +59,7 @@ private function processImageBackground($backgroundString)
5559
$backgroundArray = [];
5660
if (preg_match($pattern, $backgroundString, $backgroundArray)) {
5761
array_shift($backgroundArray);
62+
$backgroundArray = array_map('intval', $backgroundArray);
5863
}
5964
return $backgroundArray;
6065
}

app/code/Magento/Catalog/Test/Unit/Model/ImageExtractorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ protected function setUp()
2323
public function testProcess()
2424
{
2525
$expectedArray = include(__DIR__ . '/_files/converted_view.php');
26-
$this->assertEquals($expectedArray, $this->model->process($this->getDomElement(), 'media'));
26+
$this->assertSame($expectedArray, $this->model->process($this->getDomElement(), 'media'));
2727
}
2828

2929
/**

app/code/Magento/Customer/etc/webapi.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@
194194
<resource ref="anonymous"/>
195195
</resources>
196196
</route>
197+
<route url="/V1/customers/resetPassword" method="POST">
198+
<service class="Magento\Customer\Api\AccountManagementInterface" method="resetPassword"/>
199+
<resources>
200+
<resource ref="anonymous"/>
201+
</resources>
202+
</route>
197203
<route url="/V1/customers/:customerId/confirm" method="GET">
198204
<service class="Magento\Customer\Api\AccountManagementInterface" method="getConfirmationStatus"/>
199205
<resources>

app/code/Magento/Directory/etc/zip_codes.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@
319319
</zip>
320320
<zip countryCode="NL">
321321
<codes>
322-
<code id="pattern_1" active="true" example="1234 AB">^[0-9]{4}\s?[a-zA-Z]{2}$</code>
322+
<code id="pattern_1" active="true" example="1234 AB/1234AB">^[1-9][0-9]{3}\s?[a-zA-Z]{2}$</code>
323323
</codes>
324324
</zip>
325325
<zip countryCode="NO">

app/code/Magento/Quote/Model/ResourceModel/Quote/Item/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ protected function _construct()
101101
*/
102102
public function getStoreId()
103103
{
104-
return (int)$this->_quote->getStoreId();
104+
return (int)$this->_productCollectionFactory->create()->getStoreId();
105105
}
106106

107107
/**

app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ define([
5555
}
5656
});
5757

58-
var searchButton = new ControlButton(jQuery.mage.__('Add Products')),
58+
var searchButtonId = 'add_products',
59+
searchButton = new ControlButton(jQuery.mage.__('Add Products'), searchButtonId),
5960
searchAreaId = this.getAreaId('search');
6061
searchButton.onClick = function() {
6162
$(searchAreaId).show();
@@ -74,7 +75,7 @@ define([
7475

7576
this.itemsArea.onLoad = this.itemsArea.onLoad.wrap(function(proceed) {
7677
proceed();
77-
if ($(searchAreaId) && !$(searchAreaId).visible()) {
78+
if ($(searchAreaId) && !$(searchAreaId).visible() && !$(searchButtonId)) {
7879
this.addControlButton(searchButton);
7980
}
8081
});
@@ -1394,12 +1395,15 @@ define([
13941395
_label: '',
13951396
_node: null,
13961397

1397-
initialize: function(label){
1398+
initialize: function(label, id){
13981399
this._label = label;
13991400
this._node = new Element('button', {
14001401
'class': 'action-secondary action-add',
14011402
'type': 'button'
14021403
});
1404+
if (typeof id !== 'undefined') {
1405+
this._node.setAttribute('id', id)
1406+
}
14031407
},
14041408

14051409
onClick: function(){

lib/internal/Magento/Framework/Controller/Result/Redirect.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
use Magento\Framework\App;
1010
use Magento\Framework\App\Response\HttpInterface as HttpResponseInterface;
1111
use Magento\Framework\Controller\AbstractResult;
12+
use Magento\Framework\App\Response\RedirectInterface;
13+
use Magento\Framework\UrlInterface;
1214

1315
/**
1416
* In many cases controller actions may result in a redirect
@@ -18,13 +20,14 @@
1820
*/
1921
class Redirect extends AbstractResult
2022
{
23+
2124
/**
22-
* @var \Magento\Framework\App\Response\RedirectInterface
25+
* @var RedirectInterface
2326
*/
2427
protected $redirect;
2528

2629
/**
27-
* @var \Magento\Framework\UrlInterface
30+
* @var UrlInterface
2831
*/
2932
protected $urlBuilder;
3033

@@ -37,11 +40,11 @@ class Redirect extends AbstractResult
3740
* Constructor
3841
*
3942
* @param App\Response\RedirectInterface $redirect
40-
* @param \Magento\Framework\UrlInterface $urlBuilder
43+
* @param UrlInterface $urlBuilder
4144
*/
4245
public function __construct(
4346
App\Response\RedirectInterface $redirect,
44-
\Magento\Framework\UrlInterface $urlBuilder
47+
UrlInterface $urlBuilder
4548
) {
4649
$this->redirect = $redirect;
4750
$this->urlBuilder = $urlBuilder;
@@ -70,6 +73,7 @@ public function setRefererOrBaseUrl()
7073
}
7174

7275
/**
76+
* URL Setter
7377
* @param string $url
7478
* @return $this
7579
*/
@@ -97,7 +101,11 @@ public function setPath($path, array $params = [])
97101
*/
98102
protected function render(HttpResponseInterface $response)
99103
{
100-
$response->setRedirect($this->url);
104+
if (empty($this->httpResponseCode)) {
105+
$response->setRedirect($this->url);
106+
} else {
107+
$response->setRedirect($this->url, $this->httpResponseCode);
108+
}
101109
return $this;
102110
}
103111
}

lib/internal/Magento/Framework/Controller/Test/Unit/Result/RedirectTest.php

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66

77
namespace Magento\Framework\Controller\Test\Unit\Result;
88

9-
use Magento\Framework\App\Response\HttpInterface as HttpResponseInterface;
9+
use \PHPUnit\Framework\TestCase;
10+
use \Magento\Framework\App\Response\HttpInterface as HttpResponseInterface;
11+
use \Magento\Framework\App\Response\RedirectInterface;
1012
use \Magento\Framework\Controller\Result\Redirect;
13+
use \Magento\Framework\UrlInterface;
1114

12-
class RedirectTest extends \PHPUnit\Framework\TestCase
15+
class RedirectTest extends TestCase
1316
{
1417
/** @var \Magento\Framework\Controller\Result\Redirect */
1518
protected $redirect;
@@ -28,9 +31,9 @@ class RedirectTest extends \PHPUnit\Framework\TestCase
2831

2932
protected function setUp()
3033
{
31-
$this->redirectInterface = $this->createMock(\Magento\Framework\App\Response\RedirectInterface::class);
32-
$this->urlBuilder = $this->createMock(\Magento\Framework\UrlInterface::class);
33-
$this->urlInterface = $this->createMock(\Magento\Framework\UrlInterface::class);
34+
$this->redirectInterface = $this->createMock(RedirectInterface::class);
35+
$this->urlBuilder = $this->createMock(UrlInterface::class);
36+
$this->urlInterface = $this->createMock(UrlInterface::class);
3437
$this->response = $this->createMock(HttpResponseInterface::class);
3538
$this->redirect = new Redirect($this->redirectInterface, $this->urlInterface);
3639
}
@@ -39,7 +42,7 @@ public function testSetRefererUrl()
3942
{
4043
$this->redirectInterface->expects($this->once())->method('getRefererUrl');
4144
$this->assertInstanceOf(
42-
\Magento\Framework\Controller\Result\Redirect::class,
45+
Redirect::class,
4346
$this->redirect->setRefererUrl()
4447
);
4548
}
@@ -48,15 +51,15 @@ public function testSetRefererOrBaseUrl()
4851
{
4952
$this->redirectInterface->expects($this->once())->method('getRedirectUrl');
5053
$this->assertInstanceOf(
51-
\Magento\Framework\Controller\Result\Redirect::class,
54+
Redirect::class,
5255
$this->redirect->setRefererOrBaseUrl()
5356
);
5457
}
5558

5659
public function testSetUrl()
5760
{
5861
$url = 'http://test.com';
59-
$this->assertInstanceOf(\Magento\Framework\Controller\Result\Redirect::class, $this->redirect->setUrl($url));
62+
$this->assertInstanceOf(Redirect::class, $this->redirect->setUrl($url));
6063
}
6164

6265
public function testSetPath()
@@ -67,17 +70,36 @@ public function testSetPath()
6770
$this->returnValue($params)
6871
);
6972
$this->assertInstanceOf(
70-
\Magento\Framework\Controller\Result\Redirect::class,
73+
Redirect::class,
7174
$this->redirect->setPath($path, $params)
7275
);
7376
}
7477

75-
public function testRender()
78+
public function httpRedirectResponseStatusCodes()
7679
{
77-
$this->response->expects($this->once())->method('setRedirect');
78-
$this->assertInstanceOf(
79-
\Magento\Framework\Controller\Result\Redirect::class,
80-
$this->redirect->renderResult($this->response)
81-
);
80+
return [
81+
[302, null],
82+
[302, 302],
83+
[303, 303]
84+
];
85+
}
86+
87+
/**
88+
* @param int $expectedStatusCode
89+
* @param int|null $actualStatusCode
90+
* @dataProvider httpRedirectResponseStatusCodes
91+
*/
92+
public function testRender($expectedStatusCode, $actualStatusCode)
93+
{
94+
$url = 'http://test.com';
95+
$this->redirect->setUrl($url);
96+
$this->redirect->setHttpResponseCode($actualStatusCode);
97+
98+
$this->response
99+
->expects($this->once())
100+
->method('setRedirect')
101+
->with($url, $expectedStatusCode);
102+
103+
$this->redirect->renderResult($this->response);
82104
}
83105
}

lib/internal/Magento/Framework/View/Layout/etc/layout_merged.xsd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<xs:include schemaLocation="urn:magento:framework:View/Layout/etc/elements.xsd"/>
1010
<xs:include schemaLocation="urn:magento:framework:View/Layout/etc/head.xsd"/>
1111
<xs:include schemaLocation="urn:magento:framework:View/Layout/etc/body.xsd"/>
12+
<xs:include schemaLocation="urn:magento:framework:View/Layout/etc/html.xsd"/>
1213

1314
<xs:element name="layout">
1415
<xs:annotation>
@@ -45,6 +46,7 @@
4546
<xs:element ref="referenceBlock" minOccurs="0" maxOccurs="unbounded"/>
4647
<xs:element name="body" type="bodyType" minOccurs="0" maxOccurs="unbounded"/>
4748
<xs:element name="head" type="headType" minOccurs="0" maxOccurs="unbounded"/>
49+
<xs:element name="html" type="htmlType" minOccurs="0" maxOccurs="unbounded"/>
4850
</xs:choice>
4951
</xs:complexType>
5052

0 commit comments

Comments
 (0)