Skip to content

Commit fcb22a3

Browse files
committed
Merge remote-tracking branch 'origin/AC-3108-fix-deprecation-issues-part2' into delivery-bunch-w21
2 parents c1e0382 + 511c33d commit fcb22a3

File tree

15 files changed

+40
-38
lines changed

15 files changed

+40
-38
lines changed

app/code/Magento/CatalogGraphQl/Model/Resolver/Category/CanonicalUrl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function resolve(
5252
$store = $context->getExtensionAttributes()->getStore();
5353
if ($this->categoryHelper->canUseCanonicalTag($store)) {
5454
$baseUrl = $category->getUrlInstance()->getBaseUrl();
55-
return str_replace($baseUrl, '', $category->getUrl());
55+
return $category->getUrl() !== null ? str_replace($baseUrl, '', $category->getUrl()) : '';
5656
}
5757
return null;
5858
}

app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/ExtractDataFromCategoryTree.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
use Magento\CatalogGraphQl\Model\Category\Hydrator;
1111
use Magento\Catalog\Api\Data\CategoryInterface;
1212

13-
/**
14-
* Extract data from category tree
15-
*/
1613
class ExtractDataFromCategoryTree
1714
{
1815
/**
@@ -55,7 +52,8 @@ public function execute(\Iterator $iterator): array
5552
$currentCategory = $iterator->current();
5653
$iterator->next();
5754
if ($this->areParentsActive($currentCategory, $rootCategory, (array)$iterator)) {
58-
$pathElements = explode("/", $currentCategory->getPath());
55+
$pathElements = $currentCategory->getPath() !== null ?
56+
explode("/", $currentCategory->getPath()) : [''];
5957
if (empty($tree)) {
6058
$this->startCategoryFetchLevel = count($pathElements) - 1;
6159
}

app/code/Magento/CatalogGraphQl/Model/Resolver/Products/Query/Filter.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
/**
2727
* Retrieve filtered product data based off given search criteria in a format that GraphQL can interpret.
28+
*
29+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2830
*/
2931
class Filter implements ProductQueryInterface
3032
{
@@ -39,7 +41,7 @@ class Filter implements ProductQueryInterface
3941
private $productDataProvider;
4042

4143
/**
42-
* FieldSelection
44+
* @var FieldSelection
4345
*/
4446
private $fieldSelection;
4547

@@ -173,7 +175,7 @@ private function formatFilters(array $filters): array
173175
if ($condition === 'match') {
174176
// reformat 'match' filter so MySQL filtering behaves like SearchAPI filtering
175177
$condition = 'like';
176-
$value = str_replace('%', '', trim($value));
178+
$value = $value !== null ? str_replace('%', '', trim($value)) : '';
177179
if (strlen($value) < $minimumQueryLength) {
178180
throw new InputException(__('Invalid match filter'));
179181
}

app/code/Magento/CatalogImportExport/Model/Export/Product.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ protected function initCategories()
469469
$childCategory = $collection->getItemById($structure[$i]);
470470
if ($childCategory) {
471471
$name = $childCategory->getName();
472-
$path[] = $this->quoteCategoryDelimiter($name);
472+
$path[] = $name !== null ? $this->quoteCategoryDelimiter($name) : '';
473473
}
474474
}
475475
$this->_rootCategories[$category->getId()] = array_shift($path);
@@ -1124,7 +1124,7 @@ private function wrapValue($value)
11241124
{
11251125
if (!empty($this->_parameters[\Magento\ImportExport\Model\Export::FIELDS_ENCLOSURE])) {
11261126
$wrap = function ($value) {
1127-
return sprintf('"%s"', str_replace('"', '""', $value));
1127+
return sprintf('"%s"', $value !== null ? str_replace('"', '""', $value) : '');
11281128
};
11291129

11301130
$value = is_array($value) ? array_map($wrap, $value) : $wrap($value);
@@ -1200,7 +1200,7 @@ protected function hasMultiselectData($item, $storeId)
12001200
protected function collectMultiselectValues($item, $attrCode, $storeId)
12011201
{
12021202
$attrValue = $item->getData($attrCode);
1203-
$optionIds = explode(Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $attrValue);
1203+
$optionIds = $attrValue !== null ? explode(Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $attrValue) : [];
12041204
$options = array_intersect_key(
12051205
$this->_attributeValues[$attrCode],
12061206
array_flip($optionIds)

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2748,7 +2748,7 @@ private function parseAttributesWithoutWrappedValues($attributesData)
27482748
$code = '';
27492749
foreach ($attributeNameValuePairs as $attributeData) {
27502750
//process case when attribute has ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR inside its value
2751-
if (strpos($attributeData, self::PAIR_NAME_VALUE_SEPARATOR) === false) {
2751+
if ($attributeData === null || strpos($attributeData, self::PAIR_NAME_VALUE_SEPARATOR) === false) {
27522752
if (!$code) {
27532753
continue;
27542754
}
@@ -2813,7 +2813,7 @@ public function parseMultiselectValues($values, $delimiter = self::PSEUDO_MULTI_
28132813
$delimiter = $this->getMultipleValueSeparator();
28142814
}
28152815

2816-
return explode($delimiter, $values);
2816+
return $values !== null ? explode($delimiter, $values) : [];
28172817
}
28182818
if (preg_match_all('~"((?:[^"]|"")*)"~', $values, $matches)) {
28192819
return $values = array_map(
@@ -3307,7 +3307,8 @@ private function joinFilePaths(...$paths): string
33073307
{
33083308
$result = '';
33093309
if ($paths) {
3310-
$result = rtrim(array_shift($paths), DIRECTORY_SEPARATOR);
3310+
$firstPath = array_shift($paths);
3311+
$result = $firstPath !== null ? rtrim($firstPath, DIRECTORY_SEPARATOR) : '';
33113312
foreach ($paths as $path) {
33123313
$result .= DIRECTORY_SEPARATOR . ltrim($path, DIRECTORY_SEPARATOR);
33133314
}

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
namespace Magento\CatalogImportExport\Model\Import\Product;
77

88
/**
9-
* Class CategoryProcessor
10-
*
119
* @api
1210
* @since 100.0.2
1311
*/
@@ -16,7 +14,7 @@ class CategoryProcessor
1614
/**
1715
* Delimiter in category path.
1816
*/
19-
const DELIMITER_CATEGORY = '/';
17+
public const DELIMITER_CATEGORY = '/';
2018

2119
/**
2220
* @var \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory
@@ -88,7 +86,7 @@ protected function initCategories()
8886
$path = [];
8987
for ($i = 1; $i < $pathSize; $i++) {
9088
$name = $collection->getItemById((int)$structure[$i])->getName();
91-
$path[] = $this->quoteDelimiter($name);
89+
$path[] = $name !== null ? $this->quoteDelimiter($name) : '';
9290
}
9391
/** @var string $index */
9492
$index = $this->standardizeString(
@@ -135,7 +133,7 @@ protected function createCategory($name, $parentId)
135133
protected function upsertCategory($categoryPath)
136134
{
137135
/** @var string $index */
138-
$index = $this->standardizeString($categoryPath);
136+
$index = $categoryPath !== null ? $this->standardizeString($categoryPath) : '';
139137

140138
if (!isset($this->categories[$index])) {
141139
$pathParts = preg_split('~(?<!\\\)' . preg_quote(self::DELIMITER_CATEGORY, '~') . '~', $categoryPath);
@@ -165,7 +163,7 @@ protected function upsertCategory($categoryPath)
165163
public function upsertCategories($categoriesString, $categoriesSeparator)
166164
{
167165
$categoriesIds = [];
168-
$categories = explode($categoriesSeparator, $categoriesString);
166+
$categories = $categoriesString !== null ? explode($categoriesSeparator, $categoriesString) : [];
169167

170168
foreach ($categories as $category) {
171169
try {

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ public function addNameToIds(array $nameToIds): void
130130
*
131131
* @return void
132132
* @throws LocalizedException
133+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
133134
*/
134135
private function processLinkBunches(
135136
Product $importEntity,
@@ -153,7 +154,9 @@ private function processLinkBunches(
153154
$linkNameToId = $this->filterProvidedLinkTypes($rowData);
154155

155156
foreach ($linkNameToId as $linkName => $linkId) {
156-
$linkSkus = explode($importEntity->getMultipleValueSeparator(), $rowData[$linkName . 'sku']);
157+
$linkSkuKey = $linkName . 'sku';
158+
$linkSkus = isset($rowData[$linkSkuKey]) ?
159+
explode($importEntity->getMultipleValueSeparator(), $rowData[$linkSkuKey]) : [];
157160

158161
//process empty value
159162
if (!empty($linkSkus[0]) && $linkSkus[0] === $importEntity->getEmptyAttributeValueConstant()) {
@@ -388,7 +391,7 @@ private function filterValidLinks(Product $importEntity, string $sku, array $lin
388391
return array_filter(
389392
$linkSkus,
390393
function ($linkedSku) use ($sku, $importEntity) {
391-
$linkedSku = trim($linkedSku);
394+
$linkedSku = $linkedSku !== null ? trim($linkedSku) : '';
392395

393396
return (
394397
$this->skuProcessor->getNewSku($linkedSku) !== null

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ public function getExistingImages(array $bunch)
389389
$storeId = $image['store_id'];
390390
unset($image['store_id']);
391391
$sku = mb_strtolower($image['sku']);
392-
$value = ltrim($image['value'], '/\\');
392+
$value = isset($image['value']) ? ltrim($image['value'], '/\\') : '';
393393
$result[$storeId][$sku][$value] = $image;
394394
}
395395

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2072,6 +2072,7 @@ protected function _updateProducts(array $data)
20722072
* @param array $rowData
20732073
* @return array
20742074
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
2075+
* @SuppressWarnings(PHPMD.NPathComplexity)
20752076
*/
20762077
protected function _parseCustomOptions($rowData)
20772078
{
@@ -2095,7 +2096,7 @@ protected function _parseCustomOptions($rowData)
20952096
$nameAndValue = explode('=', $nameAndValue);
20962097
$value = isset($nameAndValue[1]) ? $nameAndValue[1] : '';
20972098
$value = trim($value);
2098-
$fieldName = trim($nameAndValue[0]);
2099+
$fieldName = isset($nameAndValue[0]) ? trim($nameAndValue[0]) : '';
20992100
if ($value && ($fieldName === 'name')) {
21002101
if ($name != $value) {
21012102
$name = $value;

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@ class TaxClassProcessor
2929
/**
3030
* Tax attribute code.
3131
*/
32-
const ATRR_CODE = 'tax_class_id';
32+
public const ATRR_CODE = 'tax_class_id';
3333

3434
/**
35-
* Tax classes.
36-
*
3735
* @var array
3836
*/
3937
protected $taxClasses;
@@ -114,7 +112,7 @@ protected function createTaxClass($taxClassName, AbstractType $productTypeModel)
114112
*/
115113
public function upsertTaxClass($taxClassName, AbstractType $productTypeModel)
116114
{
117-
$normalizedTaxClassName = mb_strtolower($taxClassName);
115+
$normalizedTaxClassName = $taxClassName !== null ? mb_strtolower($taxClassName) : '';
118116

119117
if ($normalizedTaxClassName === (string) self::CLASS_NONE_ID) {
120118
$normalizedTaxClassName = self::CLASS_NONE_NAME;

0 commit comments

Comments
 (0)