Skip to content

Commit 60c5beb

Browse files
author
Joan He
authored
Merge pull request #4311 from magento-arcticfoxes/2.2-develop-pr
[arcticfoxes] PR
2 parents 364645d + 21f7220 commit 60c5beb

File tree

137 files changed

+2402
-2248
lines changed

Some content is hidden

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

137 files changed

+2402
-2248
lines changed

app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Filter/TextTest.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
1010

11+
/**
12+
* Unit test for \Magento\Backend\Block\Widget\Grid\Column\Filter\Text
13+
*/
1114
class TextTest extends \PHPUnit\Framework\TestCase
1215
{
1316
/** @var \Magento\Backend\Block\Widget\Grid\Column\Filter\Text*/
@@ -31,7 +34,10 @@ protected function setUp()
3134
->setMethods(['getEscaper'])
3235
->disableOriginalConstructor()
3336
->getMock();
34-
$this->escaper = $this->createPartialMock(\Magento\Framework\Escaper::class, ['escapeHtml']);
37+
$this->escaper = $this->createPartialMock(
38+
\Magento\Framework\Escaper::class,
39+
['escapeHtml', 'escapeHtmlAttr']
40+
);
3541
$this->helper = $this->createMock(\Magento\Framework\DB\Helper::class);
3642

3743
$this->context->expects($this->once())->method('getEscaper')->willReturn($this->escaper);
@@ -60,6 +66,13 @@ public function testGetHtml()
6066
$this->block->setColumn($column);
6167

6268
$this->escaper->expects($this->any())->method('escapeHtml')->willReturn('escapedHtml');
69+
$this->escaper->expects($this->once())
70+
->method('escapeHtmlAttr')
71+
->willReturnCallback(
72+
function ($string) {
73+
return $string;
74+
}
75+
);
6376
$column->expects($this->any())->method('getId')->willReturn('id');
6477
$column->expects($this->once())->method('getHtmlId')->willReturn('htmlId');
6578

app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/AttributeSet.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
*/
1212
namespace Magento\Catalog\Block\Adminhtml\Product\Edit;
1313

14+
/**
15+
* Admin AttributeSet block
16+
*/
1417
class AttributeSet extends \Magento\Backend\Block\Widget\Form
1518
{
1619
/**
@@ -42,12 +45,14 @@ public function __construct(
4245
public function getSelectorOptions()
4346
{
4447
return [
45-
'source' => $this->getUrl('catalog/product/suggestAttributeSets'),
48+
'source' => $this->escapeUrl($this->getUrl('catalog/product/suggestAttributeSets')),
4649
'className' => 'category-select',
4750
'showRecent' => true,
4851
'storageKey' => 'product-template-key',
4952
'minLength' => 0,
50-
'currentlySelected' => $this->_coreRegistry->registry('product')->getAttributeSetId()
53+
'currentlySelected' => $this->escapeHtml(
54+
$this->_coreRegistry->registry('product')->getAttributeSetId()
55+
)
5156
];
5257
}
5358
}

app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Attributes/Search.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
*/
1212
namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Attributes;
1313

14+
/**
15+
* Admin product attribute search block
16+
*/
1417
class Search extends \Magento\Backend\Block\Widget
1518
{
1619
/**
@@ -62,13 +65,15 @@ protected function _construct()
6265
}
6366

6467
/**
68+
* Get selector options
69+
*
6570
* @return array
6671
*/
6772
public function getSelectorOptions()
6873
{
6974
$templateId = $this->_coreRegistry->registry('product')->getAttributeSetId();
7075
return [
71-
'source' => $this->getUrl('catalog/product/suggestAttributes'),
76+
'source' => $this->escapeUrl($this->getUrl('catalog/product/suggestAttributes')),
7277
'minLength' => 0,
7378
'ajaxOptions' => ['data' => ['template_id' => $templateId]],
7479
'template' => '[data-template-for="product-attribute-search-' . $this->getGroupId() . '"]',
@@ -82,6 +87,7 @@ public function getSelectorOptions()
8287
* @param string $labelPart
8388
* @param int $templateId
8489
* @return array
90+
* @SuppressWarnings(PHPMD.RequestAwareBlockMethod)
8591
*/
8692
public function getSuggestedAttributes($labelPart, $templateId = null)
8793
{
@@ -95,7 +101,9 @@ public function getSuggestedAttributes($labelPart, $templateId = null)
95101
['like' => $escapedLabelPart]
96102
);
97103

98-
$collection->setExcludeSetFilter($templateId ?: $this->getRequest()->getParam('template_id'))->setPageSize(20);
104+
$paramTemplateId = $this->getRequest()->getParam('template_id');
105+
$paramTemplateId = is_int($paramTemplateId) ? $paramTemplateId : null;
106+
$collection->setExcludeSetFilter($templateId ?: $paramTemplateId)->setPageSize(20);
99107

100108
$result = [];
101109
foreach ($collection->getItems() as $attribute) {
@@ -110,6 +118,8 @@ public function getSuggestedAttributes($labelPart, $templateId = null)
110118
}
111119

112120
/**
121+
* Get add attribute url
122+
*
113123
* @return string
114124
*/
115125
public function getAddAttributeUrl()

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

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
use Magento\Framework\Data\Collection;
1717

1818
/**
19+
* Product gallery block
20+
*
1921
* @api
2022
* @since 100.0.2
2123
*/
@@ -43,6 +45,8 @@ public function __construct(
4345
}
4446

4547
/**
48+
* Prepare layout
49+
*
4650
* @return $this
4751
*/
4852
protected function _prepareLayout()
@@ -52,6 +56,8 @@ protected function _prepareLayout()
5256
}
5357

5458
/**
59+
* Get product
60+
*
5561
* @return Product
5662
*/
5763
public function getProduct()
@@ -60,6 +66,8 @@ public function getProduct()
6066
}
6167

6268
/**
69+
* Get gallery collection
70+
*
6371
* @return Collection
6472
*/
6573
public function getGalleryCollection()
@@ -68,13 +76,16 @@ public function getGalleryCollection()
6876
}
6977

7078
/**
79+
* Get current image
80+
*
7181
* @return Image|null
82+
* @SuppressWarnings(PHPMD.RequestAwareBlockMethod)
7283
*/
7384
public function getCurrentImage()
7485
{
7586
$imageId = $this->getRequest()->getParam('image');
7687
$image = null;
77-
if ($imageId) {
88+
if (is_int($imageId)) {
7889
$image = $this->getGalleryCollection()->getItemById($imageId);
7990
}
8091

@@ -85,6 +96,8 @@ public function getCurrentImage()
8596
}
8697

8798
/**
99+
* Get image url
100+
*
88101
* @return string
89102
*/
90103
public function getImageUrl()
@@ -93,6 +106,8 @@ public function getImageUrl()
93106
}
94107

95108
/**
109+
* Get image file
110+
*
96111
* @return mixed
97112
*/
98113
public function getImageFile()
@@ -115,7 +130,7 @@ public function getImageWidth()
115130
if ($size[0] > 600) {
116131
return 600;
117132
} else {
118-
return $size[0];
133+
return (int) $size[0];
119134
}
120135
}
121136
}
@@ -124,6 +139,8 @@ public function getImageWidth()
124139
}
125140

126141
/**
142+
* Get previous image
143+
*
127144
* @return Image|false
128145
*/
129146
public function getPreviousImage()
@@ -143,6 +160,8 @@ public function getPreviousImage()
143160
}
144161

145162
/**
163+
* Get next image
164+
*
146165
* @return Image|false
147166
*/
148167
public function getNextImage()
@@ -166,6 +185,8 @@ public function getNextImage()
166185
}
167186

168187
/**
188+
* Get previous image url
189+
*
169190
* @return false|string
170191
*/
171192
public function getPreviousImageUrl()
@@ -178,6 +199,8 @@ public function getPreviousImageUrl()
178199
}
179200

180201
/**
202+
* Get next image url
203+
*
181204
* @return false|string
182205
*/
183206
public function getNextImageUrl()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ public function getAddToCartPostParams(Product $product)
364364
return [
365365
'action' => $url,
366366
'data' => [
367-
'product' => $product->getEntityId(),
367+
'product' => (int) $product->getEntityId(),
368368
ActionInterface::PARAM_NAME_URL_ENCODED => $this->urlHelper->getEncodedUrl($url),
369369
]
370370
];

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,24 +187,25 @@ public function getJsonConfig()
187187
}
188188

189189
$tierPrices = [];
190-
$tierPricesList = $product->getPriceInfo()->getPrice('tier_price')->getTierPriceList();
190+
$priceInfo = $product->getPriceInfo();
191+
$tierPricesList = $priceInfo->getPrice('tier_price')->getTierPriceList();
191192
foreach ($tierPricesList as $tierPrice) {
192-
$tierPrices[] = $tierPrice['price']->getValue();
193+
$tierPrices[] = $tierPrice['price']->getValue() * 1;
193194
}
194195
$config = [
195-
'productId' => $product->getId(),
196+
'productId' => (int)$product->getId(),
196197
'priceFormat' => $this->_localeFormat->getPriceFormat(),
197198
'prices' => [
198199
'oldPrice' => [
199-
'amount' => $product->getPriceInfo()->getPrice('regular_price')->getAmount()->getValue(),
200+
'amount' => $priceInfo->getPrice('regular_price')->getAmount()->getValue() * 1,
200201
'adjustments' => []
201202
],
202203
'basePrice' => [
203-
'amount' => $product->getPriceInfo()->getPrice('final_price')->getAmount()->getBaseAmount(),
204+
'amount' => $priceInfo->getPrice('final_price')->getAmount()->getBaseAmount() * 1,
204205
'adjustments' => []
205206
],
206207
'finalPrice' => [
207-
'amount' => $product->getPriceInfo()->getPrice('final_price')->getAmount()->getValue(),
208+
'amount' => $priceInfo->getPrice('final_price')->getAmount()->getValue() * 1,
208209
'adjustments' => []
209210
]
210211
],

app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/checkboxes/tree.phtml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
// @codingStandardsIgnoreFile
87
/**
98
* @var $block \Magento\Catalog\Block\Adminhtml\Category\Tree
109
*/

app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/edit.phtml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
*/
66

77
/**
8-
* Template for \Magento\Catalog\Block\Adminhtml\Category\Edit
8+
* @var $block \Magento\Catalog\Block\Adminhtml\Category\Edit
99
*/
1010
?>
1111
<div data-id="information-dialog-category" class="messages" style="display: none;">
1212
<div class="message message-notice">
13-
<div><?= /* @escapeNotVerified */ __('This operation can take a long time') ?></div>
13+
<div><?= $block->escapeHtml(__('This operation can take a long time')) ?></div>
1414
</div>
1515
</div>
1616
<script type="text/x-magento-init">
1717
{
1818
"*": {
19-
"categoryForm": {"refreshUrl": "<?= /* @escapeNotVerified */ $block->getRefreshPathUrl() ?>"}
19+
"categoryForm": {"refreshUrl": "<?= $block->escapeJs($block->escapeUrl($block->getRefreshPathUrl())) ?>"}
2020
}
2121
}
2222
</script>

app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/edit/assign_products.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ $gridJsObjectName = $blockGrid->getJsObjectName();
1616
{
1717
"*": {
1818
"Magento_Catalog/catalog/category/assign-products": {
19-
"selectedProducts": <?= /* @escapeNotVerified */ $block->getProductsJson() ?>,
20-
"gridJsObjectName": <?= /* @escapeNotVerified */ '"' . $gridJsObjectName . '"' ?: '{}' ?>
19+
"selectedProducts": <?= /* @noEscape */ $block->getProductsJson() ?>,
20+
"gridJsObjectName": <?= /* @noEscape */ '"' . $gridJsObjectName . '"' ?: '{}' ?>
2121
}
2222
}
2323
}

0 commit comments

Comments
 (0)