Skip to content

Commit 47ea041

Browse files
committed
Merge remote-tracking branch 'origin/2.4-develop' into CABPI-398
2 parents 4c13d93 + 2ae2987 commit 47ea041

File tree

292 files changed

+3758
-1164
lines changed

Some content is hidden

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

292 files changed

+3758
-1164
lines changed

app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,19 @@
77

88
use Magento\Catalog\Api\Data\ProductInterface;
99
use Magento\Catalog\Helper\Product\Flat\Indexer;
10+
use Magento\Catalog\Model\Product\Attribute\Source\Status;
11+
use Magento\Eav\Model\Entity\Attribute;
1012
use Magento\Framework\App\Config\ScopeConfigInterface;
13+
use Magento\Framework\App\ObjectManager;
1114
use Magento\Framework\App\ResourceConnection;
1215
use Magento\Framework\DB\Adapter\AdapterInterface;
1316
use Magento\Framework\DB\Ddl\Table;
17+
use Magento\Framework\DB\Select;
1418
use Magento\Framework\EntityManager\MetadataPool;
1519
use Magento\Framework\Exception\LocalizedException;
1620
use Magento\Framework\Exception\NoSuchEntityException;
1721
use Magento\Store\Model\StoreManagerInterface;
18-
use Magento\Catalog\Model\Product\Attribute\Source\Status;
19-
use Magento\Framework\App\ObjectManager;
20-
use Magento\Eav\Model\Entity\Attribute;
21-
use Magento\Framework\DB\Select;
22+
use Zend_Db;
2223

2324
/**
2425
* Class for building flat index
@@ -35,7 +36,7 @@ class FlatTableBuilder
3536
/**
3637
* Path to maximum available amount of indexes for flat indexer
3738
*/
38-
const XML_NODE_MAX_INDEX_COUNT = 'catalog/product/flat/max_index_count';
39+
public const XML_NODE_MAX_INDEX_COUNT = 'catalog/product/flat/max_index_count';
3940

4041
/**
4142
* @var Indexer
@@ -159,7 +160,7 @@ protected function _createTemporaryFlatTable($storeId)
159160
$indexProp['fields'],
160161
$indexProp['type']
161162
);
162-
$indexProp['type'] = strtoupper($indexProp['type']);
163+
$indexProp['type'] = strtoupper($indexProp['type'] ?? '');
163164
if ($indexProp['type'] == $upperPrimaryKey) {
164165
$indexKey = $upperPrimaryKey;
165166
} else {
@@ -354,7 +355,7 @@ protected function _updateTemporaryTableByStoreValues(
354355
);
355356
if (!empty($changedIds)) {
356357
$select->where(
357-
$this->_connection->quoteInto('et.entity_id IN (?)', $changedIds, \Zend_Db::INT_TYPE)
358+
$this->_connection->quoteInto('et.entity_id IN (?)', $changedIds, Zend_Db::INT_TYPE)
358359
);
359360
}
360361
$sql = $select->crossUpdateFromSelect(['et' => $temporaryFlatTableName]);
@@ -382,7 +383,7 @@ protected function _updateTemporaryTableByStoreValues(
382383
$this->_connection->quoteInto(
383384
'et.entity_id IN (?)',
384385
$changedIds,
385-
\Zend_Db::INT_TYPE
386+
Zend_Db::INT_TYPE
386387
)
387388
);
388389
}

app/code/Magento/Catalog/Model/Layer/Filter/DataProvider/Price.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Framework\App\Config\ScopeConfigInterface;
1010
use Magento\Framework\Registry;
1111
use Magento\Store\Model\ScopeInterface;
12+
use Magento\Catalog\Model\ResourceModel\Layer\Filter\Price as LayerFilterPrice;
1213

1314
/**
1415
* Data provider for price filter in layered navigation
@@ -18,29 +19,29 @@ class Price
1819
/**
1920
* XML configuration paths for Price Layered Navigation
2021
*/
21-
const XML_PATH_RANGE_CALCULATION = 'catalog/layered_navigation/price_range_calculation';
22+
public const XML_PATH_RANGE_CALCULATION = 'catalog/layered_navigation/price_range_calculation';
2223

23-
const XML_PATH_RANGE_STEP = 'catalog/layered_navigation/price_range_step';
24+
public const XML_PATH_RANGE_STEP = 'catalog/layered_navigation/price_range_step';
2425

25-
const XML_PATH_RANGE_MAX_INTERVALS = 'catalog/layered_navigation/price_range_max_intervals';
26+
public const XML_PATH_RANGE_MAX_INTERVALS = 'catalog/layered_navigation/price_range_max_intervals';
2627

27-
const XML_PATH_ONE_PRICE_INTERVAL = 'catalog/layered_navigation/one_price_interval';
28+
public const XML_PATH_ONE_PRICE_INTERVAL = 'catalog/layered_navigation/one_price_interval';
2829

29-
const XML_PATH_INTERVAL_DIVISION_LIMIT = 'catalog/layered_navigation/interval_division_limit';
30+
public const XML_PATH_INTERVAL_DIVISION_LIMIT = 'catalog/layered_navigation/interval_division_limit';
3031

3132
/**
3233
* Price layered navigation modes: Automatic (equalize price ranges), Automatic (equalize product counts), Manual
3334
*/
34-
const RANGE_CALCULATION_AUTO = 'auto';
35+
public const RANGE_CALCULATION_AUTO = 'auto';
3536

36-
const RANGE_CALCULATION_IMPROVED = 'improved';
37+
public const RANGE_CALCULATION_IMPROVED = 'improved';
3738

38-
const RANGE_CALCULATION_MANUAL = 'manual';
39+
public const RANGE_CALCULATION_MANUAL = 'manual';
3940

4041
/**
4142
* Minimal size of the range
4243
*/
43-
const MIN_RANGE_POWER = 10;
44+
public const MIN_RANGE_POWER = 10;
4445

4546
/**
4647
* @var Layer
@@ -58,7 +59,7 @@ class Price
5859
private $rangeItemCounts = [];
5960

6061
/**
61-
* @var \Magento\Catalog\Model\ResourceModel\Layer\Filter\Price
62+
* @var LayerFilterPrice
6263
*/
6364
private $resource;
6465

@@ -91,13 +92,13 @@ class Price
9192
* @param Layer $layer
9293
* @param Registry $coreRegistry
9394
* @param ScopeConfigInterface $scopeConfig
94-
* @param \Magento\Catalog\Model\ResourceModel\Layer\Filter\Price $resource
95+
* @param LayerFilterPrice $resource
9596
*/
9697
public function __construct(
9798
Layer $layer,
9899
Registry $coreRegistry,
99100
ScopeConfigInterface $scopeConfig,
100-
\Magento\Catalog\Model\ResourceModel\Layer\Filter\Price $resource
101+
LayerFilterPrice $resource
101102
) {
102103
$this->layer = $layer;
103104
$this->coreRegistry = $coreRegistry;
@@ -324,7 +325,7 @@ public function getPriorFilters($filterParams)
324325
*/
325326
public function validateFilter($filter)
326327
{
327-
$filter = explode('-', $filter);
328+
$filter = $filter === null ? [] : explode('-', $filter);
328329
if (count($filter) != 2) {
329330
return false;
330331
}
@@ -381,7 +382,7 @@ public function setPriorIntervals($priorInterval)
381382
/**
382383
* Get Resource model for price filter
383384
*
384-
* @return \Magento\Catalog\Model\ResourceModel\Layer\Filter\Price
385+
* @return LayerFilterPrice
385386
*/
386387
public function getResource()
387388
{

app/code/Magento/Catalog/Model/Plugin/QuoteItemProductOption.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function beforeConvert(
3434
}
3535

3636
foreach ($quoteItem->getOptions() as $itemOption) {
37-
$code = explode('_', $itemOption->getCode());
37+
$code = $itemOption->getCode() === null ? [] : explode('_', $itemOption->getCode());
3838

3939
if (!isset($code[1]) || !is_numeric($code[1])) {
4040
continue;

app/code/Magento/Catalog/Model/Product/Attribute/Backend/Sku.php

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,34 @@
77
namespace Magento\Catalog\Model\Product\Attribute\Backend;
88

99
use Magento\Catalog\Model\Product;
10+
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
11+
use Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend;
12+
use Magento\Framework\Exception\LocalizedException;
13+
use Magento\Framework\Stdlib\StringUtils;
1014

1115
/**
1216
* Catalog product SKU backend attribute model.
1317
*/
14-
class Sku extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
18+
class Sku extends AbstractBackend
1519
{
1620
/**
1721
* Maximum SKU string length
1822
*
1923
* @var string
2024
*/
21-
const SKU_MAX_LENGTH = 64;
25+
public const SKU_MAX_LENGTH = 64;
2226

2327
/**
2428
* Magento string lib
2529
*
26-
* @var \Magento\Framework\Stdlib\StringUtils
30+
* @var StringUtils
2731
*/
2832
protected $string;
2933

3034
/**
31-
* @param \Magento\Framework\Stdlib\StringUtils $string
35+
* @param StringUtils $string
3236
*/
33-
public function __construct(\Magento\Framework\Stdlib\StringUtils $string)
37+
public function __construct(StringUtils $string)
3438
{
3539
$this->string = $string;
3640
}
@@ -40,21 +44,20 @@ public function __construct(\Magento\Framework\Stdlib\StringUtils $string)
4044
*
4145
* @param Product $object
4246
* @return bool
43-
* @throws \Magento\Framework\Exception\LocalizedException
44-
* @throws \Magento\Framework\Exception\LocalizedException
47+
* @throws LocalizedException
4548
*/
4649
public function validate($object)
4750
{
4851
$attrCode = $this->getAttribute()->getAttributeCode();
49-
$value = $object->getData($attrCode);
52+
$value = $object->getData($attrCode) ?? '';
5053
if ($this->getAttribute()->getIsRequired() && strlen($value) === 0) {
51-
throw new \Magento\Framework\Exception\LocalizedException(
54+
throw new LocalizedException(
5255
__('The "%1" attribute value is empty. Set the attribute and try again.', $attrCode)
5356
);
5457
}
5558

5659
if ($this->string->strlen($object->getSku()) > self::SKU_MAX_LENGTH) {
57-
throw new \Magento\Framework\Exception\LocalizedException(
60+
throw new LocalizedException(
5861
__('SKU length should be %1 characters maximum.', self::SKU_MAX_LENGTH)
5962
);
6063
}
@@ -77,8 +80,8 @@ protected function _generateUniqueSku($object)
7780
if ($increment === null) {
7881
$increment = $this->_getLastSimilarAttributeValueIncrement($attribute, $object);
7982
}
80-
$sku = trim($attributeValue);
81-
if (strlen($sku . '-' . ++$increment) > self::SKU_MAX_LENGTH) {
83+
$sku = $attributeValue === null ? '' : trim($attributeValue);
84+
if (strlen($sku . '-' . (++$increment)) > self::SKU_MAX_LENGTH) {
8285
$sku = substr($sku, 0, -strlen($increment) - 1);
8386
}
8487
$sku = $sku . '-' . $increment;
@@ -102,15 +105,15 @@ public function beforeSave($object)
102105
/**
103106
* Return increment needed for SKU uniqueness
104107
*
105-
* @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
108+
* @param AbstractAttribute $attribute
106109
* @param Product $object
107110
* @return int
108111
*/
109112
protected function _getLastSimilarAttributeValueIncrement($attribute, $object)
110113
{
111114
$connection = $this->getAttribute()->getEntity()->getConnection();
112115
$select = $connection->select();
113-
$value = $object->getData($attribute->getAttributeCode());
116+
$value = $object->getData($attribute->getAttributeCode()) ?? '';
114117
$bind = ['attribute_code' => trim($value) . '-%'];
115118

116119
$select->from(

app/code/Magento/Catalog/Model/Product/Gallery/CreateHandler.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ class CreateHandler implements ExtensionInterface
4545
protected $attributeRepository;
4646

4747
/**
48-
* Resource model
49-
*
5048
* @var \Magento\Catalog\Model\ResourceModel\Product\Gallery
5149
* @since 101.0.0
5250
*/
@@ -174,7 +172,7 @@ public function execute($product, $arguments = [])
174172
if (!empty($image['removed'])) {
175173
$clearImages[] = $image['file'];
176174
} elseif (empty($image['value_id']) || !empty($image['recreate'])) {
177-
$newFile = $this->moveImageFromTmp($image['file']);
175+
$newFile = $this->moveImageFromTmp($image['file'] ?? '');
178176
$image['new_file'] = $newFile;
179177
$newImages[$image['file']] = $image;
180178
$image['file'] = $newFile;
@@ -193,7 +191,7 @@ public function execute($product, $arguments = [])
193191
if (empty($image['value_id']) || !empty($image['removed'])) {
194192
continue;
195193
}
196-
$duplicate[$image['value_id']] = $this->copyImage($image['file']);
194+
$duplicate[$image['value_id']] = $this->copyImage($image['file'] ?? '');
197195
$image['new_file'] = $duplicate[$image['value_id']];
198196
$newImages[$image['file']] = $image;
199197
}

app/code/Magento/Catalog/Model/Product/Gallery/Processor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ protected function getFilenameFromTmp($file)
417417
*/
418418
public function duplicateImageFromTmp($file)
419419
{
420-
$file = $this->getFilenameFromTmp($file);
420+
$file = $this->getFilenameFromTmp((string)$file);
421421

422422
$destinationFile = $this->getUniqueFileName($file, true);
423423
if ($this->fileStorageDb->checkDbUsage()) {

app/code/Magento/Catalog/Model/Product/Image.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ public function setBackgroundColor(array $rgbArray)
396396
public function setSize($size)
397397
{
398398
// determine width and height from string
399-
list($width, $height) = explode('x', strtolower($size), 2);
399+
list($width, $height) = explode('x', strtolower((string)$size), 2);
400400
foreach (['width', 'height'] as $wh) {
401401
${$wh}
402402
= (int)${$wh};

app/code/Magento/Catalog/Model/Product/Media/Config.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
class Config implements ConfigInterface
2020
{
2121
/**
22-
* Store manager
23-
*
2422
* @var StoreManagerInterface
2523
*/
2624
protected $storeManager;
@@ -170,7 +168,7 @@ public function getTmpMediaPath($file)
170168
*/
171169
protected function _prepareFile($file)
172170
{
173-
return ltrim(str_replace('\\', '/', $file), '/');
171+
return $file === null ? '' : ltrim(str_replace('\\', '/', $file), '/');
174172
}
175173

176174
/**

app/code/Magento/Catalog/Model/Product/Option/Type/File.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
4747
private $mediaDirectory;
4848

4949
/**
50-
* Core file storage database
51-
*
5250
* @var \Magento\MediaStorage\Helper\File\Storage\Database
5351
*/
5452
protected $_coreFileStorageDatabase = null;
@@ -66,8 +64,6 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
6664
protected $_urlBuilder;
6765

6866
/**
69-
* Item option factory
70-
*
7167
* @var \Magento\Quote\Model\Quote\Item\OptionFactory
7268
*/
7369
protected $_itemOptionFactory;
@@ -425,7 +421,7 @@ protected function _unserializeValue($value)
425421
*/
426422
public function getPrintableOptionValue($optionValue)
427423
{
428-
return strip_tags($this->getFormattedOptionValue($optionValue));
424+
return strip_tags($this->getFormattedOptionValue($optionValue) ?? '');
429425
}
430426

431427
/**
@@ -463,7 +459,7 @@ public function getEditableOptionValue($optionValue)
463459
public function parseOptionValue($optionValue, $productOptionValues)
464460
{
465461
// search quote item option Id in option value
466-
if (preg_match('/\[([0-9]+)\]/', $optionValue, $matches)) {
462+
if ($optionValue !== null && preg_match('/\[([0-9]+)\]/', $optionValue, $matches)) {
467463
$confItemOptionId = $matches[1];
468464
$option = $this->_itemOptionFactory->create()->load($confItemOptionId);
469465
if ($this->serializer->unserialize($option->getValue()) !== null) {

app/code/Magento/Catalog/Model/Product/Option/Type/Select.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public function getEditableOptionValue($optionValue)
175175
$option = $this->getOption();
176176
$result = '';
177177
if (!$this->_isSingleSelection()) {
178-
foreach (explode(',', $optionValue) as $_value) {
178+
foreach (explode(',', (string)$optionValue) as $_value) {
179179
$_result = $option->getValueById($_value);
180180
if ($_result) {
181181
$result .= $_result->getTitle() . ', ';
@@ -216,7 +216,7 @@ public function parseOptionValue($optionValue, $productOptionValues)
216216
$values = [];
217217
if (!$this->_isSingleSelection()) {
218218
foreach (explode(',', $optionValue) as $value) {
219-
$value = trim($value);
219+
$value = $value === null ? '' : trim($value);
220220
if (array_key_exists($value, $productOptionValues)) {
221221
$values[] = $productOptionValues[$value];
222222
}
@@ -240,7 +240,7 @@ public function parseOptionValue($optionValue, $productOptionValues)
240240
public function prepareOptionValueForRequest($optionValue)
241241
{
242242
if (!$this->_isSingleSelection()) {
243-
return explode(',', $optionValue);
243+
return explode(',', (string)$optionValue);
244244
}
245245
return $optionValue;
246246
}
@@ -258,7 +258,7 @@ public function getOptionPrice($optionValue, $basePrice)
258258
$result = 0;
259259

260260
if (!$this->_isSingleSelection()) {
261-
foreach (explode(',', $optionValue) as $value) {
261+
foreach (explode(',', (string)$optionValue) as $value) {
262262
$_result = $option->getValueById($value);
263263
if ($_result) {
264264
$result += $this->getCalculatedOptionValue($option, $_result, $basePrice);
@@ -309,7 +309,7 @@ public function getOptionSku($optionValue, $skuDelimiter)
309309

310310
if (!$this->_isSingleSelection()) {
311311
$skus = [];
312-
foreach (explode(',', $optionValue) as $value) {
312+
foreach (explode(',', (string)$optionValue) as $value) {
313313
$optionSku = $option->getValueById($value);
314314
if ($optionSku) {
315315
$skus[] = $optionSku->getSku();

0 commit comments

Comments
 (0)