Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 05c5ce7

Browse files
author
Magento CICD
authored
merge magento/2.2-develop into magento-helix/MAGETWO-80811
2 parents 15d9280 + 9304040 commit 05c5ce7

File tree

33 files changed

+921
-71
lines changed

33 files changed

+921
-71
lines changed

app/code/Magento/Backend/Controller/Adminhtml/Noroute/Index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function execute()
4141
{
4242
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
4343
$resultPage = $this->resultPageFactory->create();
44-
$resultPage->setStatusHeader(404, '1.1', 'Forbidden');
44+
$resultPage->setStatusHeader(404, '1.1', 'Not Found');
4545
$resultPage->setHeader('Status', '404 File not found');
4646
$resultPage->addHandle('adminhtml_noroute');
4747
return $resultPage;

app/code/Magento/Backend/etc/adminhtml/di.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,9 @@
147147
</argument>
148148
</arguments>
149149
</type>
150+
<type name="Magento\Framework\View\Layout\Generator\Block">
151+
<arguments>
152+
<argument name="defaultClass" xsi:type="string">Magento\Backend\Block\Template</argument>
153+
</arguments>
154+
</type>
150155
</config>

app/code/Magento/Bundle/Model/OptionRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public function save(
208208
}
209209
} else {
210210
if (!$existingOption->getOptionId()) {
211-
throw new NoSuchEntityException('Requested option doesn\'t exist');
211+
throw new NoSuchEntityException(__('Requested option doesn\'t exist'));
212212
}
213213

214214
$option->setData(array_merge($existingOption->getData(), $option->getData()));

app/code/Magento/Checkout/view/frontend/web/js/region-updater.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ define([
206206
regionInput.removeClass('required-entry');
207207
}
208208

209-
regionList.removeClass('required-entry').hide();
209+
regionList.removeClass('required-entry').prop('disabled', 'disabled').hide();
210210
regionInput.show();
211211
label.attr('for', regionInput.attr('id'));
212212
}

app/code/Magento/Review/Block/Product/ReviewRenderer.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ public function getReviewsSummaryHtml(
5757
$templateType = self::DEFAULT_VIEW,
5858
$displayIfNoReviews = false
5959
) {
60+
if (!$product->getRatingSummary()) {
61+
$this->_reviewFactory->create()->getEntitySummary($product, $this->_storeManager->getStore()->getId());
62+
}
63+
6064
if (!$product->getRatingSummary() && !$displayIfNoReviews) {
6165
return '';
6266
}
@@ -68,9 +72,6 @@ public function getReviewsSummaryHtml(
6872

6973
$this->setDisplayIfEmpty($displayIfNoReviews);
7074

71-
if (!$product->getRatingSummary()) {
72-
$this->_reviewFactory->create()->getEntitySummary($product, $this->_storeManager->getStore()->getId());
73-
}
7475
$this->setProduct($product);
7576

7677
return $this->toHtml();

app/code/Magento/Search/view/frontend/web/form-mini.js

Lines changed: 42 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -286,46 +286,50 @@ define([
286286
$.getJSON(this.options.url, {
287287
q: value
288288
}, $.proxy(function (data) {
289-
$.each(data, function (index, element) {
290-
var html;
291-
292-
element.index = index;
293-
html = template({
294-
data: element
289+
if (data.length) {
290+
$.each(data, function (index, element) {
291+
var html;
292+
293+
element.index = index;
294+
html = template({
295+
data: element
296+
});
297+
dropdown.append(html);
295298
});
296-
dropdown.append(html);
297-
});
298-
this.responseList.indexList = this.autoComplete.html(dropdown)
299-
.css(clonePosition)
300-
.show()
301-
.find(this.options.responseFieldElements + ':visible');
302-
303-
this._resetResponseList(false);
304-
this.element.removeAttr('aria-activedescendant');
305-
306-
if (this.responseList.indexList.length) {
307-
this._updateAriaHasPopup(true);
308-
} else {
309-
this._updateAriaHasPopup(false);
310-
}
311299

312-
this.responseList.indexList
313-
.on('click', function (e) {
314-
this.responseList.selected = $(e.currentTarget);
315-
this.searchForm.trigger('submit');
316-
}.bind(this))
317-
.on('mouseenter mouseleave', function (e) {
318-
this.responseList.indexList.removeClass(this.options.selectClass);
319-
$(e.target).addClass(this.options.selectClass);
320-
this.responseList.selected = $(e.target);
321-
this.element.attr('aria-activedescendant', $(e.target).attr('id'));
322-
}.bind(this))
323-
.on('mouseout', function (e) {
324-
if (!this._getLastElement() && this._getLastElement().hasClass(this.options.selectClass)) {
325-
$(e.target).removeClass(this.options.selectClass);
326-
this._resetResponseList(false);
327-
}
328-
}.bind(this));
300+
this.responseList.indexList = this.autoComplete.html(dropdown)
301+
.css(clonePosition)
302+
.show()
303+
.find(this.options.responseFieldElements + ':visible');
304+
305+
this._resetResponseList(false);
306+
this.element.removeAttr('aria-activedescendant');
307+
308+
if (this.responseList.indexList.length) {
309+
this._updateAriaHasPopup(true);
310+
} else {
311+
this._updateAriaHasPopup(false);
312+
}
313+
314+
this.responseList.indexList
315+
.on('click', function (e) {
316+
this.responseList.selected = $(e.currentTarget);
317+
this.searchForm.trigger('submit');
318+
}.bind(this))
319+
.on('mouseenter mouseleave', function (e) {
320+
this.responseList.indexList.removeClass(this.options.selectClass);
321+
$(e.target).addClass(this.options.selectClass);
322+
this.responseList.selected = $(e.target);
323+
this.element.attr('aria-activedescendant', $(e.target).attr('id'));
324+
}.bind(this))
325+
.on('mouseout', function (e) {
326+
if (!this._getLastElement() &&
327+
this._getLastElement().hasClass(this.options.selectClass)) {
328+
$(e.target).removeClass(this.options.selectClass);
329+
this._resetResponseList(false);
330+
}
331+
}.bind(this));
332+
}
329333
}, this));
330334
} else {
331335
this._resetResponseList(true);

app/code/Magento/Ui/Controller/Adminhtml/Index/Render.php

Lines changed: 78 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,56 @@
77

88
use Magento\Ui\Controller\Adminhtml\AbstractAction;
99
use Magento\Framework\View\Element\UiComponentInterface;
10+
use Magento\Backend\App\Action\Context;
11+
use Magento\Framework\View\Element\UiComponentFactory;
12+
use Psr\Log\LoggerInterface;
13+
use Magento\Framework\Escaper;
14+
use Magento\Framework\Controller\Result\JsonFactory;
1015

1116
class Render extends AbstractAction
1217
{
18+
/**
19+
* @var JsonFactory
20+
*/
21+
private $resultJsonFactory;
22+
23+
/**
24+
* @var Escaper
25+
*/
26+
private $escaper;
27+
28+
/**
29+
* @var LoggerInterface
30+
*/
31+
private $logger;
32+
33+
/**
34+
* @param Context $context
35+
* @param UiComponentFactory $factory
36+
* @param JsonFactory|null $resultJsonFactory
37+
* @param Escaper|null $escaper
38+
* @param LoggerInterface|null $logger
39+
*/
40+
public function __construct(
41+
Context $context,
42+
UiComponentFactory $factory,
43+
JsonFactory $resultJsonFactory = null,
44+
Escaper $escaper = null,
45+
LoggerInterface $logger = null
46+
) {
47+
parent::__construct($context, $factory);
48+
$this->resultJsonFactory = $resultJsonFactory ?: \Magento\Framework\App\ObjectManager::getInstance()
49+
->get(\Magento\Framework\Controller\Result\JsonFactory::class);
50+
$this->escaper = $escaper ?: \Magento\Framework\App\ObjectManager::getInstance()
51+
->get(\Magento\Framework\Escaper::class);
52+
$this->logger = $logger ?: \Magento\Framework\App\ObjectManager::getInstance()
53+
->get(\Psr\Log\LoggerInterface::class);
54+
}
55+
1356
/**
1457
* Action for AJAX request
1558
*
16-
* @return void
59+
* @return void|\Magento\Framework\Controller\ResultInterface
1760
*/
1861
public function execute()
1962
{
@@ -22,10 +65,40 @@ public function execute()
2265
return;
2366
}
2467

25-
$component = $this->factory->create($this->_request->getParam('namespace'));
26-
if ($this->validateAclResource($component->getContext()->getDataProvider()->getConfigData())) {
27-
$this->prepareComponent($component);
28-
$this->_response->appendBody((string) $component->render());
68+
try {
69+
$component = $this->factory->create($this->_request->getParam('namespace'));
70+
if ($this->validateAclResource($component->getContext()->getDataProvider()->getConfigData())) {
71+
$this->prepareComponent($component);
72+
$this->_response->appendBody((string) $component->render());
73+
}
74+
} catch (\Magento\Framework\Exception\LocalizedException $e) {
75+
$this->logger->critical($e);
76+
$result = [
77+
'error' => $this->escaper->escapeHtml($e->getMessage()),
78+
'errorcode' => $this->escaper->escapeHtml($e->getCode())
79+
];
80+
/** @var \Magento\Framework\Controller\Result\Json $resultJson */
81+
$resultJson = $this->resultJsonFactory->create();
82+
$resultJson->setStatusHeader(
83+
\Zend\Http\Response::STATUS_CODE_400,
84+
\Zend\Http\AbstractMessage::VERSION_11,
85+
'Bad Request'
86+
);
87+
return $resultJson->setData($result);
88+
} catch (\Exception $e) {
89+
$this->logger->critical($e);
90+
$result = [
91+
'error' => _('UI component could not be rendered because of system exception'),
92+
'errorcode' => $this->escaper->escapeHtml($e->getCode())
93+
];
94+
/** @var \Magento\Framework\Controller\Result\Json $resultJson */
95+
$resultJson = $this->resultJsonFactory->create();
96+
$resultJson->setStatusHeader(
97+
\Zend\Http\Response::STATUS_CODE_400,
98+
\Zend\Http\AbstractMessage::VERSION_11,
99+
'Bad Request'
100+
);
101+
return $resultJson->setData($result);
29102
}
30103
}
31104

app/code/Magento/Ui/Test/Unit/Controller/Adminhtml/Index/RenderTest.php

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
*/
66
namespace Magento\Ui\Test\Unit\Controller\Adminhtml\Index;
77

8-
use \Magento\Ui\Controller\Adminhtml\Index\Render;
8+
use Magento\Ui\Controller\Adminhtml\Index\Render;
9+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
910

1011
/**
1112
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -17,6 +18,11 @@ class RenderTest extends \PHPUnit\Framework\TestCase
1718
*/
1819
private $render;
1920

21+
/**
22+
* @var ObjectManagerHelper
23+
*/
24+
private $objectManagerHelper;
25+
2026
/**
2127
* @var \PHPUnit_Framework_MockObject_MockObject
2228
*/
@@ -73,6 +79,16 @@ class RenderTest extends \PHPUnit\Framework\TestCase
7379
*/
7480
private $uiComponentMock;
7581

82+
/**
83+
* @var \Magento\Framework\Controller\Result\JsonFactory|\PHPUnit_Framework_MockObject_MockObject
84+
*/
85+
private $resultJsonFactoryMock;
86+
87+
/**
88+
* @var \Psr\Log\LoggerInterface|\PHPUnit_Framework_MockObject_MockObject
89+
*/
90+
private $loggerMock;
91+
7692
protected function setUp()
7793
{
7894
$this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class)
@@ -114,6 +130,14 @@ protected function setUp()
114130
['render']
115131
);
116132

133+
$this->resultJsonFactoryMock = $this->getMockBuilder(
134+
\Magento\Framework\Controller\Result\JsonFactory::class
135+
)
136+
->disableOriginalConstructor()
137+
->getMock();
138+
139+
$this->loggerMock = $this->getMockForAbstractClass(\Psr\Log\LoggerInterface::class);
140+
117141
$this->contextMock->expects($this->any())
118142
->method('getRequest')
119143
->willReturn($this->requestMock);
@@ -136,7 +160,70 @@ protected function setUp()
136160
->method('getDataProvider')
137161
->willReturn($this->dataProviderMock);
138162

139-
$this->render = new Render($this->contextMock, $this->uiFactoryMock);
163+
$this->objectManagerHelper = new ObjectManagerHelper($this);
164+
165+
$this->render = $this->objectManagerHelper->getObject(
166+
\Magento\Ui\Controller\Adminhtml\Index\Render::class,
167+
[
168+
'context' => $this->contextMock,
169+
'factory' => $this->uiFactoryMock,
170+
'resultJsonFactory' => $this->resultJsonFactoryMock,
171+
'logger' => $this->loggerMock
172+
]
173+
);
174+
}
175+
176+
public function testExecuteAjaxRequestException()
177+
{
178+
$name = 'test-name';
179+
$renderedData = '<html>data</html>';
180+
181+
$this->requestMock->expects($this->any())
182+
->method('getParam')
183+
->with('namespace')
184+
->willReturn($name);
185+
$this->requestMock->expects($this->any())
186+
->method('getParams')
187+
->willReturn([]);
188+
$this->responseMock->expects($this->once())
189+
->method('appendBody')
190+
->willThrowException(new \Exception('exception'));
191+
192+
$jsonResultMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Json::class)
193+
->disableOriginalConstructor()
194+
->setMethods(['setData'])
195+
->getMock();
196+
197+
$this->resultJsonFactoryMock->expects($this->once())
198+
->method('create')
199+
->willReturn($jsonResultMock);
200+
201+
$jsonResultMock->expects($this->once())
202+
->method('setData')
203+
->willReturnSelf();
204+
205+
$this->loggerMock->expects($this->once())
206+
->method('critical')
207+
->willReturnSelf();
208+
209+
$this->dataProviderMock->expects($this->once())
210+
->method('getConfigData')
211+
->willReturn([]);
212+
213+
$this->uiComponentMock->expects($this->once())
214+
->method('render')
215+
->willReturn($renderedData);
216+
$this->uiComponentMock->expects($this->once())
217+
->method('getChildComponents')
218+
->willReturn([]);
219+
$this->uiComponentMock->expects($this->once())
220+
->method('getContext')
221+
->willReturn($this->uiComponentContextMock);
222+
$this->uiFactoryMock->expects($this->once())
223+
->method('create')
224+
->willReturn($this->uiComponentMock);
225+
226+
$this->render->executeAjaxRequest();
140227
}
141228

142229
public function testExecuteAjaxRequest()

0 commit comments

Comments
 (0)