Skip to content

Commit 4451859

Browse files
Merge branch 'MC-22738' into 2.3-develop-com-pr6
2 parents ca1bd70 + 35ed9a2 commit 4451859

File tree

80 files changed

+1912
-149
lines changed

Some content is hidden

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

80 files changed

+1912
-149
lines changed

app/code/Magento/Backend/Block/Widget/Grid.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,10 @@ protected function _addColumnFilterToCollection($column)
300300
if ($this->getCollection()) {
301301
$field = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex();
302302
if ($column->getFilterConditionCallback()) {
303-
call_user_func($column->getFilterConditionCallback(), $this->getCollection(), $column);
303+
$column->getFilterConditionCallback()[0]->{$column->getFilterConditionCallback()[1]}(
304+
$this->getCollection(),
305+
$column
306+
);
304307
} else {
305308
$condition = $column->getFilter()->getCondition();
306309
if ($field && isset($condition)) {
@@ -363,7 +366,7 @@ protected function _prepareCollection()
363366
$this->_setFilterValues($data);
364367
} elseif ($filter && is_array($filter)) {
365368
$this->_setFilterValues($filter);
366-
} elseif (0 !== sizeof($this->_defaultFilter)) {
369+
} elseif (0 !== count($this->_defaultFilter)) {
367370
$this->_setFilterValues($this->_defaultFilter);
368371
}
369372

app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Action.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function render(\Magento\Framework\DataObject $row)
4747
return ' ';
4848
}
4949

50-
if (sizeof($actions) == 1 && !$this->getColumn()->getNoLink()) {
50+
if (count($actions) == 1 && !$this->getColumn()->getNoLink()) {
5151
foreach ($actions as $action) {
5252
if (is_array($action)) {
5353
return $this->_toLinkHtml($action, $row);
@@ -104,6 +104,7 @@ protected function _toLinkHtml($action, \Magento\Framework\DataObject $row)
104104
$this->_transformActionData($action, $actionCaption, $row);
105105

106106
if (isset($action['confirm'])) {
107+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
107108
$action['onclick'] = 'return window.confirm(\'' . addslashes(
108109
$this->escapeHtml($action['confirm'])
109110
) . '\')';
@@ -117,8 +118,8 @@ protected function _toLinkHtml($action, \Magento\Framework\DataObject $row)
117118
/**
118119
* Prepares action data for html render
119120
*
120-
* @param array &$action
121-
* @param string &$actionCaption
121+
* @param &array $action
122+
* @param &string $actionCaption
122123
* @param \Magento\Framework\DataObject $row
123124
* @return $this
124125
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
@@ -144,7 +145,7 @@ protected function _transformActionData(&$action, &$actionCaption, \Magento\Fram
144145
if (is_array($action['url']) && isset($action['field'])) {
145146
$params = [$action['field'] => $this->_getValue($row)];
146147
if (isset($action['url']['params'])) {
147-
$params = array_merge($action['url']['params'], $params);
148+
$params[] = $action['url']['params'];
148149
}
149150
$action['href'] = $this->getUrl($action['url']['base'], $params);
150151
unset($action['field']);

app/code/Magento/Backend/Helper/Dashboard/AbstractDashboard.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
/**
99
* Adminhtml abstract dashboard helper.
1010
*
11+
* phpcs:disable Magento2.Classes.AbstractApi
1112
* @api
1213
* @since 100.0.2
1314
*/
@@ -28,6 +29,8 @@ abstract class AbstractDashboard extends \Magento\Framework\App\Helper\AbstractH
2829
protected $_params = [];
2930

3031
/**
32+
* Return collections
33+
*
3134
* @return array|\Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
3235
*/
3336
public function getCollection()
@@ -39,6 +42,8 @@ public function getCollection()
3942
}
4043

4144
/**
45+
* Init collections
46+
*
4247
* @return void
4348
*/
4449
abstract protected function _initCollection();
@@ -54,14 +59,18 @@ public function getItems()
5459
}
5560

5661
/**
62+
* Return items count
63+
*
5764
* @return int
5865
*/
5966
public function getCount()
6067
{
61-
return sizeof($this->getItems());
68+
return count($this->getItems());
6269
}
6370

6471
/**
72+
* Return column
73+
*
6574
* @param string $index
6675
* @return array
6776
*/
@@ -85,6 +94,8 @@ public function getColumn($index)
8594
}
8695

8796
/**
97+
* Set params with value
98+
*
8899
* @param string $name
89100
* @param mixed $value
90101
* @return void
@@ -95,6 +106,8 @@ public function setParam($name, $value)
95106
}
96107

97108
/**
109+
* Set params
110+
*
98111
* @param array $params
99112
* @return void
100113
*/
@@ -104,6 +117,8 @@ public function setParams(array $params)
104117
}
105118

106119
/**
120+
* Get params with name
121+
*
107122
* @param string $name
108123
* @return mixed
109124
*/
@@ -117,6 +132,8 @@ public function getParam($name)
117132
}
118133

119134
/**
135+
* Get params
136+
*
120137
* @return array
121138
*/
122139
public function getParams()

app/code/Magento/Backend/Helper/Dashboard/Data.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function getStores()
6868
*/
6969
public function countStores()
7070
{
71-
return sizeof($this->_stores->getItems());
71+
return count($this->_stores->getItems());
7272
}
7373

7474
/**
@@ -88,15 +88,15 @@ public function getDatePeriods()
8888
}
8989

9090
/**
91-
* Create data hash to ensure that we got valid
92-
* data and it is not changed by some one else.
91+
* Create data hash to ensure that we got valid data and it is not changed by some one else.
9392
*
9493
* @param string $data
9594
* @return string
9695
*/
9796
public function getChartDataHash($data)
9897
{
9998
$secret = $this->_installDate;
99+
// phpcs:disable Magento2.Security.InsecureFunction.FoundWithAlternative
100100
return md5($data . $secret);
101101
}
102102
}

app/code/Magento/Catalog/Model/Entity/Product/Attribute/Design/Options/Container.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Container extends \Magento\Eav\Model\Entity\Attribute\Source\Config
2121
public function getOptionText($value)
2222
{
2323
$options = $this->getAllOptions();
24-
if (sizeof($options) > 0) {
24+
if (count($options) > 0) {
2525
foreach ($options as $option) {
2626
if (isset($option['value']) && $option['value'] == $value) {
2727
return __($option['label']);

app/code/Magento/Catalog/Test/Unit/Model/Product/Type/PriceTest.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,13 @@ public function testTierPrices($priceScope, $expectedWebsiteId)
165165
$this->websiteMock->expects($this->any())->method('getId')->will($this->returnValue($expectedWebsiteId));
166166
$this->tpFactory->expects($this->any())
167167
->method('create')
168-
->will($this->returnCallback(function () {
169-
return $this->objectManagerHelper->getObject(\Magento\Catalog\Model\Product\TierPrice::class);
170-
}));
168+
->will(
169+
$this->returnCallback(
170+
function () {
171+
return $this->objectManagerHelper->getObject(\Magento\Catalog\Model\Product\TierPrice::class);
172+
}
173+
)
174+
);
171175

172176
// create sample TierPrice objects that would be coming from a REST call
173177
$tierPriceExtensionMock = $this->getMockBuilder(ProductTierPriceExtensionInterface::class)
@@ -198,9 +202,10 @@ public function testTierPrices($priceScope, $expectedWebsiteId)
198202
$tpArray = $this->product->getData($this::KEY_TIER_PRICE);
199203
$this->assertNotNull($tpArray);
200204
$this->assertTrue(is_array($tpArray));
201-
$this->assertEquals(sizeof($tps), sizeof($tpArray));
205+
$this->assertEquals(count($tps), count($tpArray));
202206

203-
for ($i = 0; $i < sizeof($tps); $i++) {
207+
$count = count($tps);
208+
for ($i = 0; $i < $count; $i++) {
204209
$tpData = $tpArray[$i];
205210
$this->assertEquals($expectedWebsiteId, $tpData['website_id'], 'Website Id does not match');
206211
$this->assertEquals($tps[$i]->getValue(), $tpData['price'], 'Price/Value does not match');
@@ -226,12 +231,13 @@ public function testTierPrices($priceScope, $expectedWebsiteId)
226231
$tpRests = $this->model->getTierPrices($this->product);
227232
$this->assertNotNull($tpRests);
228233
$this->assertTrue(is_array($tpRests));
229-
$this->assertEquals(sizeof($tps), sizeof($tpRests));
234+
$this->assertEquals(count($tps), count($tpRests));
230235
foreach ($tpRests as $tpRest) {
231236
$this->assertEquals(50, $tpRest->getExtensionAttributes()->getPercentageValue());
232237
}
233238

234-
for ($i = 0; $i < sizeof($tps); $i++) {
239+
$count = count($tps);
240+
for ($i = 0; $i < $count; $i++) {
235241
$this->assertEquals(
236242
$tps[$i]->getValue(),
237243
$tpRests[$i]->getValue(),

app/code/Magento/Catalog/view/frontend/templates/product/compare/list.phtml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@
130130
default :?>
131131
<?php if (is_string($block->getProductAttributeValue($item, $attribute))) :?>
132132
<?= /* @noEscape */ $helper->productAttribute($item, $block->getProductAttributeValue($item, $attribute), $attribute->getAttributeCode()) ?>
133+
<?php else : ?>
134+
<?= $block->escapeHtml($helper->productAttribute($item, $block->getProductAttributeValue($item, $attribute), $attribute->getAttributeCode())) ?>
133135
<?php endif; ?>
134136
<?php break;
135137
} ?>

app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2086,7 +2086,9 @@ protected function _parseCustomOptions($rowData)
20862086
}
20872087
}
20882088
}
2089-
$options[$name][$k]['_custom_option_store'] = $rowData[Product::COL_STORE_VIEW_CODE];
2089+
if (isset($rowData[Product::COL_STORE_VIEW_CODE])) {
2090+
$options[$name][$k][self::COLUMN_STORE] = $rowData[Product::COL_STORE_VIEW_CODE];
2091+
}
20902092
$k++;
20912093
}
20922094
$rowData['custom_options'] = $options;

app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/OptionTest.php

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,77 @@ public function testValidateAmbiguousData(
776776
$this->assertEquals($errors, $resultErrors);
777777
}
778778

779+
/**
780+
* Test for row without store view code field
781+
* @param array $rowData
782+
* @param array $responseData
783+
*
784+
* @covers \Magento\CatalogImportExport\Model\Import\Product\Option::_parseCustomOptions
785+
* @dataProvider validateRowStoreViewCodeFieldDataProvider
786+
*/
787+
public function testValidateRowDataForStoreViewCodeField($rowData, $responseData)
788+
{
789+
$reflection = new \ReflectionClass(\Magento\CatalogImportExport\Model\Import\Product\Option::class);
790+
$reflectionMethod = $reflection->getMethod('_parseCustomOptions');
791+
$reflectionMethod->setAccessible(true);
792+
$result = $reflectionMethod->invoke($this->model, $rowData);
793+
$this->assertEquals($responseData, $result);
794+
}
795+
796+
/**
797+
* Data provider for test of method _parseCustomOptions
798+
*
799+
* @return array
800+
*/
801+
public function validateRowStoreViewCodeFieldDataProvider()
802+
{
803+
return [
804+
'with_store_view_code' => [
805+
'$rowData' => [
806+
'store_view_code' => '',
807+
'custom_options' =>
808+
'name=Test Field Title,type=field,required=1;sku=1-text,price=0,price_type=fixed'
809+
],
810+
'$responseData' => [
811+
'store_view_code' => '',
812+
'custom_options' => [
813+
'Test Field Title' => [
814+
[
815+
'name' => 'Test Field Title',
816+
'type' => 'field',
817+
'required' => '1',
818+
'sku' => '1-text',
819+
'price' => '0',
820+
'price_type' => 'fixed',
821+
'_custom_option_store' => ''
822+
]
823+
]
824+
]
825+
],
826+
],
827+
'without_store_view_code' => [
828+
'$rowData' => [
829+
'custom_options' =>
830+
'name=Test Field Title,type=field,required=1;sku=1-text,price=0,price_type=fixed'
831+
],
832+
'$responseData' => [
833+
'custom_options' => [
834+
'Test Field Title' => [
835+
[
836+
'name' => 'Test Field Title',
837+
'type' => 'field',
838+
'required' => '1',
839+
'sku' => '1-text',
840+
'price' => '0',
841+
'price_type' => 'fixed'
842+
]
843+
]
844+
]
845+
],
846+
]
847+
];
848+
}
849+
779850
/**
780851
* Data provider of row data and errors
781852
*

app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ protected function generalTestGetDirsCollection($path, $collectionArray = [], $e
454454
$storageCollectionMock->expects($this->once())
455455
->method('getIterator')
456456
->willReturn(new \ArrayIterator($collectionArray));
457-
$storageCollectionInvMock = $storageCollectionMock->expects($this->exactly(sizeof($expectedRemoveKeys)))
457+
$storageCollectionInvMock = $storageCollectionMock->expects($this->exactly(count($expectedRemoveKeys)))
458458
->method('removeItemByKey');
459459
call_user_func_array([$storageCollectionInvMock, 'withConsecutive'], $expectedRemoveKeys);
460460

0 commit comments

Comments
 (0)