Skip to content

Commit c2e1037

Browse files
committed
Merge remote-tracking branch 'origin/AC-3108-fix-deprecation-issues' into delivery-bunch-w20
2 parents 3668b6b + 07194b5 commit c2e1037

File tree

15 files changed

+51
-55
lines changed

15 files changed

+51
-55
lines changed

app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Category.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ class Category extends \Magento\Framework\Data\Form\Element\Multiselect
2222
protected $_layout;
2323

2424
/**
25-
* Backend data
26-
*
2725
* @var \Magento\Backend\Helper\Data
2826
*/
2927
protected $_backendData;
@@ -96,7 +94,7 @@ public function getValues()
9694
$collection = $this->_getCategoriesCollection();
9795
$values = $this->getValue();
9896
if (!is_array($values)) {
99-
$values = explode(',', $values);
97+
$values = $values !== null ? explode(',', $values) : [];
10098
}
10199
$collection->addAttributeToSelect('name');
102100
$collection->addIdFilter($values);

app/code/Magento/Catalog/Block/Product/ProductList/Toolbar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ public function setDefaultOrder($field)
340340
*/
341341
public function setDefaultDirection($dir)
342342
{
343-
if (in_array(strtolower($dir), ['asc', 'desc'])) {
343+
if ($dir && in_array(strtolower($dir), ['asc', 'desc'])) {
344344
$this->_direction = strtolower($dir);
345345
}
346346
return $this;

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

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

7-
/**
8-
* Simple product data view
9-
*
10-
* @author Magento Core Team <core@magentocommerce.com>
11-
*/
127
namespace Magento\Catalog\Block\Product\View;
138

149
use Magento\Catalog\Block\Product\Context;
@@ -137,15 +132,16 @@ public function getGalleryImagesJson()
137132
$imagesItems = [];
138133
/** @var DataObject $image */
139134
foreach ($this->getGalleryImages() as $image) {
135+
$mediaType = $image->getMediaType();
140136
$imageItem = new DataObject(
141137
[
142138
'thumb' => $image->getData('small_image_url'),
143139
'img' => $image->getData('medium_image_url'),
144140
'full' => $image->getData('large_image_url'),
145-
'caption' => ($image->getLabel() ?: $this->getProduct()->getName()),
141+
'caption' => $image->getLabel() ?: $this->getProduct()->getName(),
146142
'position' => $image->getData('position'),
147-
'isMain' => $this->isMainImage($image),
148-
'type' => str_replace('external-', '', $image->getMediaType()),
143+
'isMain' => $this->isMainImage($image),
144+
'type' => $mediaType !== null ? str_replace('external-', '', $mediaType) : '',
149145
'videoUrl' => $image->getVideoUrl(),
150146
]
151147
);

app/code/Magento/Catalog/Block/Product/View/Options/Type/Date.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ class Date extends \Magento\Catalog\Block\Product\View\Options\AbstractOptions
2626
protected $_fillLeadingZeros = true;
2727

2828
/**
29-
* Catalog product option type date
30-
*
3129
* @var \Magento\Catalog\Model\Product\Option\Type\Date
3230
*/
3331
protected $_catalogProductOptionTypeDate;
@@ -137,7 +135,7 @@ public function getCalendarDateHtml()
137135
public function getDropDownsDateHtml()
138136
{
139137
$fieldsSeparator = '&nbsp;';
140-
$fieldsOrder = $this->_catalogProductOptionTypeDate->getConfigData('date_fields_order');
138+
$fieldsOrder = $this->_catalogProductOptionTypeDate->getConfigData('date_fields_order') ?? '';
141139
$fieldsOrder = str_replace(',', $fieldsSeparator, $fieldsOrder);
142140

143141
$monthsHtml = $this->_getSelectFromToHtml('month', 1, 12);

app/code/Magento/Catalog/Block/Widget/Link.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public function getLabel()
145145
if ($this->getData('anchor_text')) {
146146
$this->_anchorText = $this->getData('anchor_text');
147147
} elseif ($this->_entityResource) {
148-
$idPath = explode('/', $this->_getData('id_path'));
148+
$idPath = $this->_getData('id_path') !== null ? explode('/', $this->_getData('id_path')) : [];
149149
if (isset($idPath[1])) {
150150
$id = $idPath[1];
151151
if ($id) {

app/code/Magento/Catalog/Model/Api/SearchCriteria/CollectionProcessor/ConditionProcessor/ProductCategoryCondition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function build(Filter $filter): string
8484
*/
8585
private function getCategoryIds(Filter $filter): array
8686
{
87-
$categoryIds = explode(',', $filter->getValue());
87+
$categoryIds = $filter->getValue() !== null ? explode(',', $filter->getValue()) : [];
8888
$childCategoryIds = [];
8989

9090
foreach ($categoryIds as $categoryId) {

app/code/Magento/Catalog/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/ProductWebsiteFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ProductWebsiteFilter implements CustomFilterInterface
2222
public function apply(Filter $filter, AbstractDb $collection)
2323
{
2424
$value = $filter->getValue();
25-
if (strpos($value, ',') !== false) {
25+
if ($value !== null && strpos($value, ',') !== false) {
2626
$value = explode(',', $value);
2727
}
2828
/** @var Collection $collection */

app/code/Magento/Catalog/Model/Category/FileInfo.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class FileInfo
2626
/**
2727
* Path in /pub/media directory
2828
*/
29-
const ENTITY_MEDIA_PATH = '/catalog/category';
29+
public const ENTITY_MEDIA_PATH = '/catalog/category';
3030

3131
/**
3232
* @var Filesystem
@@ -54,8 +54,6 @@ class FileInfo
5454
private $pubDirectory;
5555

5656
/**
57-
* Store manager
58-
*
5957
* @var \Magento\Store\Model\StoreManagerInterface
6058
*/
6159
private $storeManager;
@@ -216,7 +214,7 @@ private function removeStorePath(string $path): string
216214
{
217215
$result = $path;
218216
try {
219-
$storeUrl = $this->storeManager->getStore()->getBaseUrl();
217+
$storeUrl = $this->storeManager->getStore()->getBaseUrl() ?? '';
220218
} catch (NoSuchEntityException $e) {
221219
return $result;
222220
}

app/code/Magento/Catalog/Model/CategoryManagement.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ public function move($categoryId, $parentId, $afterId = null)
123123

124124
if ($parentCategory->hasChildren()) {
125125
$parentChildren = $parentCategory->getChildren();
126-
$categoryIds = explode(',', $parentChildren);
126+
$categoryIds = $parentChildren !== null ? explode(',', $parentChildren) : [];
127127
$lastId = array_pop($categoryIds);
128128
$afterId = ($afterId === null || $afterId > $lastId) ? $lastId : $afterId;
129129
}
130-
$parentPath = $parentCategory->getPath();
130+
$parentPath = $parentCategory->getPath() ?? '';
131131
$path = $model->getPath();
132132
if ($path && strpos($parentPath, $path) === 0) {
133133
throw new \Magento\Framework\Exception\LocalizedException(

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

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Magento\Catalog\Model;
88

9+
use Magento\Eav\Model\ResourceModel\Entity\Type\CollectionFactory;
910
use Magento\Framework\Serialize\SerializerInterface;
1011

1112
/**
@@ -18,7 +19,7 @@
1819
*/
1920
class Config extends \Magento\Eav\Model\Config
2021
{
21-
const XML_PATH_LIST_DEFAULT_SORT_BY = 'catalog/frontend/default_sort_by';
22+
public const XML_PATH_LIST_DEFAULT_SORT_BY = 'catalog/frontend/default_sort_by';
2223

2324
/**
2425
* @var mixed
@@ -84,43 +85,31 @@ class Config extends \Magento\Eav\Model\Config
8485
protected $_scopeConfig;
8586

8687
/**
87-
* Eav config
88-
*
8988
* @var \Magento\Eav\Model\Config
9089
*/
9190
protected $_eavConfig;
9291

9392
/**
94-
* Store manager
95-
*
9693
* @var \Magento\Store\Model\StoreManagerInterface
9794
*/
9895
protected $_storeManager;
9996

10097
/**
101-
* Set collection factory
102-
*
10398
* @var \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory
10499
*/
105100
protected $_setCollectionFactory;
106101

107102
/**
108-
* Group collection factory
109-
*
110103
* @var \Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\CollectionFactory
111104
*/
112105
protected $_groupCollectionFactory;
113106

114107
/**
115-
* Product type factory
116-
*
117108
* @var \Magento\Catalog\Model\Product\TypeFactory
118109
*/
119110
protected $_productTypeFactory;
120111

121112
/**
122-
* Config factory
123-
*
124113
* @var \Magento\Catalog\Model\ResourceModel\ConfigFactory
125114
*/
126115
protected $_configFactory;
@@ -130,7 +119,7 @@ class Config extends \Magento\Eav\Model\Config
130119
*
131120
* @param \Magento\Framework\App\CacheInterface $cache
132121
* @param \Magento\Eav\Model\Entity\TypeFactory $entityTypeFactory
133-
* @param \Magento\Eav\Model\ResourceModel\Entity\Type\CollectionFactory $entityTypeCollectionFactory,
122+
* @param \Magento\Eav\Model\ResourceModel\Entity\Type\CollectionFactory $entityTypeCollectionFactory
134123
* @param \Magento\Framework\App\Cache\StateInterface $cacheState
135124
* @param \Magento\Framework\Validator\UniversalFactory $universalFactory
136125
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
@@ -207,6 +196,8 @@ public function getStoreId()
207196
}
208197

209198
/**
199+
* Loads all Attribute Sets
200+
*
210201
* @return $this
211202
*/
212203
public function loadAttributeSets()
@@ -229,6 +220,8 @@ public function loadAttributeSets()
229220
}
230221

231222
/**
223+
* Returns Attribute's Set Name
224+
*
232225
* @param string|int|float $entityTypeId
233226
* @param float|int $id
234227
* @return false|string
@@ -249,6 +242,8 @@ public function getAttributeSetName($entityTypeId, $id)
249242
}
250243

251244
/**
245+
* Returns Attribute's Set ID
246+
*
252247
* @param string|int|float $entityTypeId
253248
* @param string|null $name
254249
* @return false|string|int
@@ -263,13 +258,15 @@ public function getAttributeSetId($entityTypeId, $name = null)
263258
if (!is_numeric($entityTypeId)) {
264259
$entityTypeId = $this->getEntityType($entityTypeId)->getId();
265260
}
266-
$name = strtolower($name);
261+
$name = $name !== null ? strtolower($name) : '';
267262
return isset(
268263
$this->_attributeSetsByName[$entityTypeId][$name]
269264
) ? $this->_attributeSetsByName[$entityTypeId][$name] : false;
270265
}
271266

272267
/**
268+
* Loads all attribute Groups
269+
*
273270
* @return $this
274271
*/
275272
public function loadAttributeGroups()
@@ -292,6 +289,8 @@ public function loadAttributeGroups()
292289
}
293290

294291
/**
292+
* Returns the Attribute's Group Name
293+
*
295294
* @param float|int|string $attributeSetId
296295
* @param float|int|string $id
297296
* @return bool|string
@@ -313,6 +312,8 @@ public function getAttributeGroupName($attributeSetId, $id)
313312
}
314313

315314
/**
315+
* Returns the Attribute's Group ID
316+
*
316317
* @param float|int|string $attributeSetId
317318
* @param string $name
318319
* @return bool|string|int|float
@@ -328,13 +329,15 @@ public function getAttributeGroupId($attributeSetId, $name)
328329
if (!is_numeric($attributeSetId)) {
329330
$attributeSetId = $this->getAttributeSetId($attributeSetId);
330331
}
331-
$name = strtolower($name);
332+
$name = $name !== null ? strtolower($name) : '';
332333
return isset(
333334
$this->_attributeGroupsByName[$attributeSetId][$name]
334335
) ? $this->_attributeGroupsByName[$attributeSetId][$name] : false;
335336
}
336337

337338
/**
339+
* Loads all product types
340+
*
338341
* @return $this
339342
*/
340343
public function loadProductTypes()
@@ -356,6 +359,8 @@ public function loadProductTypes()
356359
}
357360

358361
/**
362+
* Returns ID of the Product Type
363+
*
359364
* @param string $name
360365
* @return false|string
361366
*/
@@ -367,11 +372,13 @@ public function getProductTypeId($name)
367372

368373
$this->loadProductTypes();
369374

370-
$name = strtolower($name);
375+
$name = $name !== null ? strtolower($name) : '';
371376
return isset($this->_productTypesByName[$name]) ? $this->_productTypesByName[$name] : false;
372377
}
373378

374379
/**
380+
* Returns the name of Product Type
381+
*
375382
* @param float|int|string $id
376383
* @return false|string
377384
*/
@@ -387,6 +394,8 @@ public function getProductTypeName($id)
387394
}
388395

389396
/**
397+
* Return Source option ID if exists
398+
*
390399
* @param \Magento\Framework\DataObject $source
391400
* @param string $value
392401
* @return null|mixed
@@ -468,8 +477,7 @@ public function getAttributesUsedForSortBy()
468477
}
469478

470479
/**
471-
* Retrieve Attributes Used for Sort by as array
472-
* key = code, value = name
480+
* Retrieve Attributes Used for Sort by as array: key = code, value = name
473481
*
474482
* @return array
475483
*/

0 commit comments

Comments
 (0)