Skip to content

Commit f629205

Browse files
anzinandrewbess
authored andcommitted
AC-3109 fixed logic affected by "RFC: Deprecate passing null"
1 parent 9661597 commit f629205

File tree

13 files changed

+52
-60
lines changed

13 files changed

+52
-60
lines changed

app/code/Magento/Config/Model/Config/Structure/Mapper/Helper/RelativePathConverter.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ class RelativePathConverter
2222
* @param string $relativePath
2323
* @return string
2424
* @throws \InvalidArgumentException
25+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
2526
*/
2627
public function convert($nodePath, $relativePath)
2728
{
28-
$nodePath = trim($nodePath);
29-
$relativePath = trim($relativePath);
29+
$nodePath = $nodePath !== null ? trim($nodePath) : '';
30+
$relativePath = $relativePath !== null ? trim($relativePath) : '';
3031

3132
if (empty($nodePath) || empty($relativePath)) {
3233
throw new \InvalidArgumentException('Invalid arguments');

app/code/Magento/Config/Setup/Patch/Data/UnsetTinymce3.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
namespace Magento\Config\Setup\Patch\Data;
88

9+
use Magento\Framework\Setup\ModuleDataSetupInterface;
910
use Magento\Framework\Setup\Patch\DataPatchInterface;
1011
use Magento\Framework\Setup\Patch\PatchVersionInterface;
11-
use Magento\Framework\Setup\ModuleDataSetupInterface;
1212

1313
/**
1414
* Update config to Tinymce4 if Tinymce3 adapter is used.
@@ -46,7 +46,7 @@ public function apply()
4646
)
4747
->where('path = ?', 'cms/wysiwyg/editor');
4848

49-
if (strpos($connection->fetchOne($select), 'Tinymce3/tinymce3Adapter') !== false) {
49+
if (strpos($connection->fetchOne($select) ?? '', 'Tinymce3/tinymce3Adapter') !== false) {
5050
$row = [
5151
'value' => 'mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter'
5252
];

app/code/Magento/ConfigurableImportExport/Model/Import/Product/Type/Configurable.php

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22
/**
3-
* Import entity configurable product type model
4-
*
53
* Copyright © Magento, Inc. All rights reserved.
64
* See COPYING.txt for license details.
75
*/
@@ -25,21 +23,21 @@ class Configurable extends \Magento\CatalogImportExport\Model\Import\Product\Typ
2523
/**
2624
* Error codes.
2725
*/
28-
const ERROR_ATTRIBUTE_CODE_DOES_NOT_EXIST = 'attrCodeDoesNotExist';
26+
public const ERROR_ATTRIBUTE_CODE_DOES_NOT_EXIST = 'attrCodeDoesNotExist';
2927

30-
const ERROR_ATTRIBUTE_CODE_NOT_GLOBAL_SCOPE = 'attrCodeNotGlobalScope';
28+
public const ERROR_ATTRIBUTE_CODE_NOT_GLOBAL_SCOPE = 'attrCodeNotGlobalScope';
3129

32-
const ERROR_ATTRIBUTE_CODE_NOT_TYPE_SELECT = 'attrCodeNotTypeSelect';
30+
public const ERROR_ATTRIBUTE_CODE_NOT_TYPE_SELECT = 'attrCodeNotTypeSelect';
3331

34-
const ERROR_ATTRIBUTE_CODE_IS_NOT_SUPER = 'attrCodeIsNotSuper';
32+
public const ERROR_ATTRIBUTE_CODE_IS_NOT_SUPER = 'attrCodeIsNotSuper';
3533

36-
const ERROR_INVALID_OPTION_VALUE = 'invalidOptionValue';
34+
public const ERROR_INVALID_OPTION_VALUE = 'invalidOptionValue';
3735

38-
const ERROR_INVALID_WEBSITE = 'invalidSuperAttrWebsite';
36+
public const ERROR_INVALID_WEBSITE = 'invalidSuperAttrWebsite';
3937

40-
const ERROR_DUPLICATED_VARIATIONS = 'duplicatedVariations';
38+
public const ERROR_DUPLICATED_VARIATIONS = 'duplicatedVariations';
4139

42-
const ERROR_UNIDENTIFIABLE_VARIATION = 'unidentifiableVariation';
40+
public const ERROR_UNIDENTIFIABLE_VARIATION = 'unidentifiableVariation';
4341

4442
/**
4543
* Validation failure message template definitions
@@ -170,15 +168,11 @@ class Configurable extends \Magento\CatalogImportExport\Model\Import\Product\Typ
170168
protected $_productColFac;
171169

172170
/**
173-
* Product data.
174-
*
175171
* @var array
176172
*/
177173
protected $_productData;
178174

179175
/**
180-
* Product super data.
181-
*
182176
* @var array
183177
*/
184178
protected $_productSuperData;
@@ -191,8 +185,6 @@ class Configurable extends \Magento\CatalogImportExport\Model\Import\Product\Typ
191185
protected $_simpleIdsToDelete;
192186

193187
/**
194-
* Super attributes data.
195-
*
196188
* @var array
197189
*/
198190
protected $_superAttributesData;
@@ -205,8 +197,6 @@ class Configurable extends \Magento\CatalogImportExport\Model\Import\Product\Typ
205197
protected $_nextAttrId;
206198

207199
/**
208-
* Product entity identifier field
209-
*
210200
* @var string
211201
*/
212202
private $productEntityIdentifierField;
@@ -449,8 +439,8 @@ protected function _loadSkuSuperDataForBunch(array $bunch)
449439
$oldSku = $this->_entityModel->getOldSku();
450440
$productIds = [];
451441
foreach ($bunch as $rowData) {
452-
$sku = strtolower($rowData[ImportProduct::COL_SKU]);
453-
$productData = isset($newSku[$sku]) ? $newSku[$sku] : $oldSku[$sku];
442+
$sku = isset($rowData[ImportProduct::COL_SKU]) ? strtolower($rowData[ImportProduct::COL_SKU]) : '';
443+
$productData = $newSku[$sku] ?? $oldSku[$sku];
454444
$productIds[] = $productData[$this->getProductEntityLinkField()];
455445
}
456446

@@ -574,10 +564,10 @@ protected function _parseVariations($rowData)
574564
$fieldAndValuePairs = [];
575565
foreach ($fieldAndValuePairsText as $nameAndValue) {
576566
$nameAndValue = explode(ImportProduct::PAIR_NAME_VALUE_SEPARATOR, $nameAndValue, 2);
577-
if (!empty($nameAndValue)) {
567+
if ($nameAndValue) {
578568
$value = isset($nameAndValue[1]) ? trim($nameAndValue[1]) : '';
579569
// Ignoring field names' case.
580-
$fieldName = strtolower(trim($nameAndValue[0]));
570+
$fieldName = isset($nameAndValue[0]) ? strtolower(trim($nameAndValue[0])) : '';
581571
if ($fieldName) {
582572
$fieldAndValuePairs[$fieldName] = $value;
583573
}
@@ -588,7 +578,7 @@ protected function _parseVariations($rowData)
588578
$position = 0;
589579
$additionalRow['_super_products_sku'] = strtolower($fieldAndValuePairs['sku']);
590580
unset($fieldAndValuePairs['sku']);
591-
$additionalRow['display'] = isset($fieldAndValuePairs['display']) ? $fieldAndValuePairs['display'] : 1;
581+
$additionalRow['display'] = $fieldAndValuePairs['display'] ?? 1;
592582
unset($fieldAndValuePairs['display']);
593583
foreach ($fieldAndValuePairs as $attrCode => $attrValue) {
594584
$additionalRow['_super_attribute_code'] = $attrCode;
@@ -635,9 +625,9 @@ protected function _parseVariationLabels($rowData)
635625

636626
foreach ($pairFieldAndValue as $nameAndValue) {
637627
$nameAndValue = explode(ImportProduct::PAIR_NAME_VALUE_SEPARATOR, $nameAndValue);
638-
if (!empty($nameAndValue)) {
628+
if ($nameAndValue) {
639629
$value = isset($nameAndValue[1]) ? trim($nameAndValue[1]) : '';
640-
$attrCode = trim($nameAndValue[0]);
630+
$attrCode = isset($nameAndValue[0]) ? trim($nameAndValue[0]) : '';
641631
if ($attrCode) {
642632
$labels[$attrCode] = $value;
643633
}
@@ -790,8 +780,10 @@ protected function _collectAssocIds($data)
790780
if (isset($data['display']) && $data['display'] == 0) {
791781
$this->_simpleIdsToDelete[] = $superProductRowId;
792782
} else {
793-
$this->_productSuperData['assoc_ids'][$superProductRowId] = true;
794-
$this->_productSuperData['assoc_entity_ids'][$superProductRowId] = $superProductEntityId;
783+
if (isset($superProductEntityId)) {
784+
$this->_productSuperData['assoc_ids'][$superProductRowId] = true;
785+
$this->_productSuperData['assoc_entity_ids'][$superProductRowId] = $superProductEntityId;
786+
}
795787
}
796788
}
797789
}
@@ -814,9 +806,7 @@ protected function _collectSuperDataLabels($data, $productSuperAttrId, $productI
814806
'product_super_attribute_id' => $productSuperAttrId,
815807
'position' => $data['_super_attribute_position'],
816808
];
817-
$label = isset($variationLabels[$data['_super_attribute_code']])
818-
? $variationLabels[$data['_super_attribute_code']]
819-
: $attrParams['frontend_label'];
809+
$label = $variationLabels[$data['_super_attribute_code']] ?? $attrParams['frontend_label'];
820810
$this->_superAttributesData['labels'][$productSuperAttrId] = [
821811
'product_super_attribute_id' => $productSuperAttrId,
822812
'store_id' => 0,
@@ -868,7 +858,7 @@ public function saveData()
868858
if (ImportProduct::SCOPE_DEFAULT == $scope &&
869859
!empty($rowData[ImportProduct::COL_SKU])) {
870860
$sku = strtolower($rowData[ImportProduct::COL_SKU]);
871-
$this->_productData = isset($newSku[$sku]) ? $newSku[$sku] : $oldSku[$sku];
861+
$this->_productData = $newSku[$sku] ?? $oldSku[$sku];
872862

873863
if ($this->_type != $this->_productData['type_id']) {
874864
$this->_productData = null;
@@ -898,7 +888,7 @@ protected function configurableInBunch($bunch)
898888
{
899889
$newSku = $this->_entityModel->getNewSku();
900890
foreach ($bunch as $rowNum => $rowData) {
901-
$productData = $newSku[strtolower($rowData[ImportProduct::COL_SKU])];
891+
$productData = $newSku[strtolower($rowData[ImportProduct::COL_SKU] ?? '')];
902892
if (($this->_type == $productData['type_id']) &&
903893
($rowData == $this->_entityModel->isRowAllowedToImport($rowData, $rowNum))
904894
) {

app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Attribute/Edit/Tab/Variations/Main.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ protected function _prepareForm()
3131
$fieldsToRemove = ['attribute_code', 'is_unique', 'frontend_class'];
3232

3333
foreach ($fieldset->getElements() as $element) {
34+
$elementId = $element->getId() ?? '';
35+
3436
/** @var \Magento\Framework\Data\Form\AbstractForm $element */
35-
if (substr($element->getId(), 0, strlen('default_value')) == 'default_value') {
36-
$fieldsToRemove[] = $element->getId();
37+
if (substr($elementId, 0, strlen('default_value')) == 'default_value') {
38+
$fieldsToRemove[] = $elementId;
3739
}
3840
}
3941
foreach ($fieldsToRemove as $id) {

app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ protected function getOptionImages()
268268
'caption' => $image->getLabel(),
269269
'position' => $image->getPosition(),
270270
'isMain' => $image->getFile() == $product->getImage(),
271-
'type' => str_replace('external-', '', $image->getMediaType()),
271+
'type' => $image->getMediaType() ? str_replace('external-', '', $image->getMediaType()) : '',
272272
'videoUrl' => $image->getVideoUrl(),
273273
];
274274
}

app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ protected function _prepareProduct(\Magento\Framework\DataObject $buyRequest, $p
955955
* to be sure that it will be unique as its parent
956956
*/
957957
if ($optionIds = $product->getCustomOption('option_ids')) {
958-
$optionIds = explode(',', $optionIds->getValue());
958+
$optionIds = explode(',', $optionIds->getValue() ?? '');
959959
foreach ($optionIds as $optionId) {
960960
if ($option = $product->getCustomOption('option_' . $optionId)) {
961961
$_result[0]->addCustomOption('option_' . $optionId, $option->getValue());

app/code/Magento/ConfigurableProductGraphQl/Model/Options/SelectionUidFormatter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ public function extract(array $selectionUids): array
6060
{
6161
$attributeOption = [];
6262
foreach ($selectionUids as $uid) {
63-
$optionData = explode(self::UID_SEPARATOR, $this->idEncoder->decode($uid));
63+
$decodedUid = $this->idEncoder->decode($uid);
64+
$optionData = $decodedUid !== null ? explode(self::UID_SEPARATOR, $decodedUid) : [];
6465
if (count($optionData) === 3) {
6566
$attributeOption[(int)$optionData[1]] = (int)$optionData[2];
6667
}

app/code/Magento/Cron/Model/Schedule.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function _construct()
104104
*/
105105
public function setCronExpr($expr)
106106
{
107-
$e = preg_split('#\s+#', $expr, -1, PREG_SPLIT_NO_EMPTY);
107+
$e = $expr !== null ? preg_split('#\s+#', $expr, -1, PREG_SPLIT_NO_EMPTY) : [];
108108
if (count($e) < 5 || count($e) > 6) {
109109
throw new CronException(__('Invalid cron expression: %1', $expr));
110110
}
@@ -164,7 +164,7 @@ public function matchCronExpression($expr, $num)
164164
}
165165

166166
// handle multiple options
167-
if (strpos($expr, ',') !== false) {
167+
if ($expr && strpos($expr, ',') !== false) {
168168
foreach (explode(',', $expr) as $e) {
169169
if ($this->matchCronExpression($e, $num)) {
170170
return true;
@@ -174,7 +174,7 @@ public function matchCronExpression($expr, $num)
174174
}
175175

176176
// handle modulus
177-
if (strpos($expr, '/') !== false) {
177+
if ($expr && strpos($expr, '/') !== false) {
178178
$e = explode('/', $expr);
179179
if (count($e) !== 2) {
180180
throw new CronException(__('Invalid cron expression, expecting \'match/modulus\': %1', $expr));
@@ -193,7 +193,7 @@ public function matchCronExpression($expr, $num)
193193
if ($expr === '*') {
194194
$from = 0;
195195
$to = 60;
196-
} elseif (strpos($expr, '-') !== false) {
196+
} elseif ($expr && strpos($expr, '-') !== false) {
197197
// handle range
198198
$e = explode('-', $expr);
199199
if (count($e) !== 2) {

app/code/Magento/Customer/Block/Widget/Name.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function getPrefixOptions()
107107

108108
if ($this->getObject() && !empty($prefixOptions)) {
109109
$prefixOption = $this->getObject()->getPrefix();
110-
$oldPrefix = $this->escapeHtml(trim($prefixOption));
110+
$oldPrefix = $this->escapeHtml(trim($prefixOption ?? ''));
111111
if ($prefixOption !== null && !isset($prefixOptions[$oldPrefix]) && !isset($prefixOptions[$prefixOption])) {
112112
$prefixOptions[$oldPrefix] = $oldPrefix;
113113
}
@@ -165,7 +165,7 @@ public function getSuffixOptions()
165165
$suffixOptions = $this->options->getNameSuffixOptions();
166166
if ($this->getObject() && !empty($suffixOptions)) {
167167
$suffixOption = $this->getObject()->getSuffix();
168-
$oldSuffix = $this->escapeHtml(trim($suffixOption));
168+
$oldSuffix = $this->escapeHtml(trim($suffixOption ?? ''));
169169
if ($suffixOption !== null && !isset($suffixOptions[$oldSuffix]) && !isset($suffixOptions[$suffixOption])) {
170170
$suffixOptions[$oldSuffix] = $oldSuffix;
171171
}

app/code/Magento/Customer/Controller/Adminhtml/Address/Viewfile.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Viewfile extends Action implements HttpGetActionInterface
3131
/**
3232
* Authorization level of a basic admin session
3333
*/
34-
const ADMIN_RESOURCE = 'Magento_Customer::manage';
34+
public const ADMIN_RESOURCE = 'Magento_Customer::manage';
3535

3636
/**
3737
* @var RawFactory
@@ -159,17 +159,16 @@ public function execute()
159159
*/
160160
private function getFileParams() : array
161161
{
162-
$file = null;
163162
$plain = false;
164-
if ($this->getRequest()->getParam('file')) {
163+
if ($this->getRequest()->getParam('file', '')) {
165164
// download file
166165
$file = $this->urlDecoder->decode(
167-
$this->getRequest()->getParam('file')
166+
$this->getRequest()->getParam('file', '')
168167
);
169-
} elseif ($this->getRequest()->getParam('image')) {
168+
} elseif ($this->getRequest()->getParam('image', '')) {
170169
// show plain image
171170
$file = $this->urlDecoder->decode(
172-
$this->getRequest()->getParam('image')
171+
$this->getRequest()->getParam('image', '')
173172
);
174173
$plain = true;
175174
} else {

0 commit comments

Comments
 (0)