Skip to content

Commit 65634d8

Browse files
Merge pull request #5857 from magento-borg/2.4.1-bugfixes-070620
Resolved Issues: - MC-34467: Updated jQuery File Upload plugin - MC-34174: Adding sorting validation - MC-35076: Catalog Event Update
2 parents 75502d9 + cc1d5dc commit 65634d8

File tree

62 files changed

+10147
-2772
lines changed

Some content is hidden

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

62 files changed

+10147
-2772
lines changed

app/code/Magento/Backend/view/adminhtml/web/js/media-uploader.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ define([
3737
progressTmpl = mageTemplate('[data-template="uploader"]'),
3838
isResizeEnabled = this.options.isResizeEnabled,
3939
resizeConfiguration = {
40-
action: 'resize',
40+
action: 'resizeImage',
4141
maxWidth: this.options.maxWidth,
4242
maxHeight: this.options.maxHeight
4343
};
4444

4545
if (!isResizeEnabled) {
4646
resizeConfiguration = {
47-
action: 'resize'
47+
action: 'resizeImage'
4848
};
4949
}
5050

@@ -131,13 +131,13 @@ define([
131131
});
132132

133133
this.element.find('input[type=file]').fileupload('option', {
134-
process: [{
135-
action: 'load',
134+
processQueue: [{
135+
action: 'loadImage',
136136
fileTypes: /^image\/(gif|jpeg|png)$/
137137
},
138138
resizeConfiguration,
139139
{
140-
action: 'save'
140+
action: 'saveImage'
141141
}]
142142
});
143143
}

app/code/Magento/Catalog/Ui/Component/Listing/Columns/AttributeSetId.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace Magento\Catalog\Ui\Component\Listing\Columns;
99

1010
/**
11-
* Attribute set listing column component
11+
* AttributeSetId listing column component.
1212
*/
1313
class AttributeSetId extends \Magento\Ui\Component\Listing\Columns\Column
1414
{
@@ -23,6 +23,7 @@ protected function applySorting()
2323
&& !empty($sorting['field'])
2424
&& !empty($sorting['direction'])
2525
&& $sorting['field'] === $this->getName()
26+
&& in_array(strtoupper($sorting['direction']), ['ASC', 'DESC'], true)
2627
) {
2728
$collection = $this->getContext()->getDataProvider()->getCollection();
2829
$collection->joinField(

app/code/Magento/Catalog/Ui/Component/Listing/Columns/Websites.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ protected function applySorting()
118118
&& !empty($sorting['field'])
119119
&& !empty($sorting['direction'])
120120
&& $sorting['field'] === $this->getName()
121+
&& in_array(strtoupper($sorting['direction']), ['ASC', 'DESC'], true)
121122
) {
122123
/** @var \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection $collection */
123124
$collection = $this->getContext()->getDataProvider()->getCollection();

app/code/Magento/ImportExport/Block/Adminhtml/Import/Frame/Result.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function addError($message)
102102
$this->addError($row);
103103
}
104104
} else {
105-
$this->_messages['error'][] = $message;
105+
$this->_messages['error'][] = $this->escapeHtml($message);
106106
}
107107
return $this;
108108
}
@@ -140,7 +140,8 @@ public function addSuccess($message, $appendImportButton = false)
140140
$this->addSuccess($row);
141141
}
142142
} else {
143-
$this->_messages['success'][] = $message . ($appendImportButton ? $this->getImportButtonHtml() : '');
143+
$escapedMessage = $this->escapeHtml($message);
144+
$this->_messages['success'][] = $escapedMessage . ($appendImportButton ? $this->getImportButtonHtml() : '');
144145
}
145146
return $this;
146147
}

app/code/Magento/ImportExport/Controller/Adminhtml/ImportResult.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public function __construct(
5656
}
5757

5858
/**
59+
* Add Error Messages for Import
60+
*
5961
* @param \Magento\Framework\View\Element\AbstractBlock $resultBlock
6062
* @param ProcessingErrorAggregatorInterface $errorAggregator
6163
* @return $this
@@ -68,7 +70,7 @@ protected function addErrorMessages(
6870
$message = '';
6971
$counter = 0;
7072
foreach ($this->getErrorMessages($errorAggregator) as $error) {
71-
$message .= ++$counter . '. ' . $error . '<br>';
73+
$message .= (++$counter) . '. ' . $error . '<br>';
7274
if ($counter >= self::LIMIT_ERRORS_MESSAGE) {
7375
break;
7476
}
@@ -88,7 +90,7 @@ protected function addErrorMessages(
8890
. '<a href="'
8991
. $this->createDownloadUrlImportHistoryFile($this->createErrorReport($errorAggregator))
9092
. '">' . __('Download full report') . '</a><br>'
91-
. '<div class="import-error-list">' . $message . '</div></div>'
93+
. '<div class="import-error-list">' . $resultBlock->escapeHtml($message) . '</div></div>'
9294
);
9395
} catch (\Exception $e) {
9496
foreach ($this->getErrorMessages($errorAggregator) as $errorMessage) {
@@ -101,6 +103,8 @@ protected function addErrorMessages(
101103
}
102104

103105
/**
106+
* Get all Error Messages from Import Results
107+
*
104108
* @param \Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface $errorAggregator
105109
* @return array
106110
*/
@@ -115,6 +119,8 @@ protected function getErrorMessages(ProcessingErrorAggregatorInterface $errorAgg
115119
}
116120

117121
/**
122+
* Get System Generated Exception
123+
*
118124
* @param ProcessingErrorAggregatorInterface $errorAggregator
119125
* @return \Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingError[]
120126
*/
@@ -124,6 +130,8 @@ protected function getSystemExceptions(ProcessingErrorAggregatorInterface $error
124130
}
125131

126132
/**
133+
* Generate Error Report File
134+
*
127135
* @param ProcessingErrorAggregatorInterface $errorAggregator
128136
* @return string
129137
*/
@@ -141,6 +149,8 @@ protected function createErrorReport(ProcessingErrorAggregatorInterface $errorAg
141149
}
142150

143151
/**
152+
* Get Import History Url
153+
*
144154
* @param string $fileName
145155
* @return string
146156
*/
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\ImportExport\Test\Unit\Block\Adminhtml\Import\Frame;
9+
10+
use Magento\Framework\Escaper;
11+
use PHPUnit\Framework\MockObject\MockObject;
12+
use PHPUnit\Framework\TestCase;
13+
use Magento\ImportExport\Block\Adminhtml\Import\Frame\Result;
14+
use Magento\Backend\Block\Template\Context;
15+
use Magento\Framework\Json\EncoderInterface;
16+
17+
/**
18+
* Unit test for Magento\ImportExport\Block\Adminhtml\Import\Frame\Result
19+
*
20+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
21+
*/
22+
class ResultTest extends TestCase
23+
{
24+
/**
25+
* @var Result
26+
*/
27+
private $result;
28+
29+
/**
30+
* @var EncoderInterface|MockObject
31+
*/
32+
private $encoderMock;
33+
34+
/**
35+
* @var Context|MockObject
36+
*/
37+
private $contextMock;
38+
39+
/**
40+
* @var Escaper|MockObject
41+
*/
42+
private $escaperMock;
43+
44+
/**
45+
* Initialize Class Dependencies
46+
*
47+
* @inheritDoc
48+
*/
49+
protected function setUp(): void
50+
{
51+
$this->contextMock = $this->createMock(Context::class);
52+
$this->encoderMock = $this->getMockBuilder(EncoderInterface::class)
53+
->disableOriginalConstructor()
54+
->getMockForAbstractClass();
55+
56+
$this->escaperMock = $this->createPartialMock(Escaper::class, ['escapeHtml']);
57+
$this->contextMock->expects($this->once())->method('getEscaper')->willReturn($this->escaperMock);
58+
$this->result = new Result(
59+
$this->contextMock,
60+
$this->encoderMock
61+
);
62+
}
63+
64+
/**
65+
* Test error message
66+
*
67+
* @return void
68+
*/
69+
public function testAddError(): void
70+
{
71+
$errors = ['first error', 'second error','third error'];
72+
$this->escaperMock
73+
->expects($this->exactly(count($errors)))
74+
->method('escapeHtml')
75+
->willReturnOnConsecutiveCalls(...array_values($errors));
76+
77+
$this->result->addError($errors);
78+
$this->assertEquals(count($errors), count($this->result->getMessages()['error']));
79+
}
80+
81+
/**
82+
* Test success message
83+
*
84+
* @return void
85+
*/
86+
public function testAddSuccess(): void
87+
{
88+
$success = ['first message', 'second message','third message'];
89+
$this->escaperMock
90+
->expects($this->exactly(count($success)))
91+
->method('escapeHtml')
92+
->willReturnOnConsecutiveCalls(...array_values($success));
93+
94+
$this->result->addSuccess($success);
95+
$this->assertEquals(count($success), count($this->result->getMessages()['success']));
96+
}
97+
98+
/**
99+
* Test Add Notice message
100+
*
101+
* @return void
102+
*/
103+
public function testAddNotice(): void
104+
{
105+
$notice = ['notice 1', 'notice 2','notice 3'];
106+
107+
$this->result->addNotice($notice);
108+
$this->assertEquals(count($notice), count($this->result->getMessages()['notice']));
109+
}
110+
}

app/code/Magento/ProductVideo/view/adminhtml/web/js/get-video-information.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ define([
129129
* Abstract destroying command
130130
*/
131131
destroy: function () {
132-
this._player.destroy();
132+
if (this._player) {
133+
this._player.destroy();
134+
}
133135
},
134136

135137
/**
@@ -288,7 +290,10 @@ define([
288290
*/
289291
destroy: function () {
290292
this.stop();
291-
this._player.destroy();
293+
294+
if (this._player) {
295+
this._player.destroy();
296+
}
292297
}
293298
});
294299

app/code/Magento/ProductVideo/view/adminhtml/web/js/new-video-dialog.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,13 @@ define([
580580
* @private
581581
*/
582582
_onImageLoaded: function (result, file, oldFile, callback) {
583-
var data = JSON.parse(result);
583+
var data;
584+
585+
try {
586+
data = JSON.parse(result);
587+
} catch (e) {
588+
data = result;
589+
}
584590

585591
if (this.element.find('#video_url').parent().find('.image-upload-error').length > 0) {
586592
this.element.find('.image-upload-error').remove();

app/code/Magento/Theme/view/base/requirejs-config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ var config = {
3131
paths: {
3232
'jquery/validate': 'jquery/jquery.validate',
3333
'jquery/hover-intent': 'jquery/jquery.hoverIntent',
34-
'jquery/file-uploader': 'jquery/fileUploader/jquery.fileupload-fp',
34+
'jquery/file-uploader': 'jquery/fileUploader/jquery.fileuploader',
3535
'prototype': 'legacy-build.min',
3636
'jquery/jquery-storageapi': 'jquery/jquery.storageapi.min',
3737
'text': 'mage/requirejs/text',

app/code/Magento/Ui/Component/Listing/Columns/Column.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
*/
66
namespace Magento\Ui\Component\Listing\Columns;
77

8-
use Magento\Ui\Component\AbstractComponent;
8+
use Magento\Framework\View\Element\UiComponent\ContextInterface;
99
use Magento\Framework\View\Element\UiComponentFactory;
1010
use Magento\Framework\View\Element\UiComponentInterface;
11-
use Magento\Framework\View\Element\UiComponent\ContextInterface;
11+
use Magento\Ui\Component\AbstractComponent;
1212

1313
/**
1414
* @api
@@ -64,6 +64,7 @@ public function getComponentName()
6464
* Prepare component configuration
6565
*
6666
* @return void
67+
* @throws \Magento\Framework\Exception\LocalizedException
6768
*/
6869
public function prepare()
6970
{
@@ -97,18 +98,19 @@ public function prepare()
9798
}
9899

99100
/**
100-
* To prepare items of a column
101+
* Prepares items of a column
101102
*
102103
* @param array $items
103104
* @return array
104105
*/
105-
public function prepareItems(array & $items)
106+
public function prepareItems(array &$items)
106107
{
107108
return $items;
108109
}
109110

110111
/**
111-
* Add field to select
112+
* Adds additional field to select object
113+
*
112114
* @return void
113115
*/
114116
protected function addFieldToSelect()
@@ -131,6 +133,7 @@ protected function applySorting()
131133
&& !empty($sorting['field'])
132134
&& !empty($sorting['direction'])
133135
&& $sorting['field'] === $this->getName()
136+
&& in_array(strtoupper($sorting['direction']), ['ASC', 'DESC'], true)
134137
) {
135138
$this->getContext()->getDataProvider()->addOrder(
136139
$this->getName(),

0 commit comments

Comments
 (0)