Skip to content

Commit b47541f

Browse files
karyna-tandrewbess
authored andcommitted
AC-3108: Fix possible deprecation issues with 8.1
1 parent b092dd6 commit b47541f

File tree

16 files changed

+55
-46
lines changed

16 files changed

+55
-46
lines changed

app/code/Magento/Config/Model/Config/Backend/File/RequestData.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@ public function getName($path)
3838
*/
3939
protected function _getParam($paramName, $path)
4040
{
41-
$pathParts = explode('/', $path);
41+
$pathParts = $path !== null ? explode('/', $path) : [];
4242
array_shift($pathParts);
4343
$fieldId = array_pop($pathParts);
4444
$firstGroupId = array_shift($pathParts);
45+
// phpcs:ignore Magento2.Security.Superglobal
4546
if (!isset($_FILES['groups'][$paramName])) {
4647
return null;
4748
}
49+
// phpcs:disable Magento2.Security.Superglobal
4850
$groupData = $_FILES['groups'][$paramName];
4951
if (isset($groupData[$firstGroupId])) {
5052
$groupData = $groupData[$firstGroupId];

app/code/Magento/Config/Model/Config/Backend/Locale.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,18 @@ public function __construct(
7373
}
7474

7575
/**
76-
* @return $this
76+
* @inheritdoc
77+
*
7778
* @throws \Magento\Framework\Exception\LocalizedException
79+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
7880
*/
7981
public function afterSave()
8082
{
8183
/** @var $collection \Magento\Config\Model\ResourceModel\Config\Data\Collection */
8284
$collection = $this->_configsFactory->create();
8385
$collection->addPathFilter('currency/options');
8486

85-
$values = explode(',', $this->getValue());
87+
$values = $this->getValue() !== null ? explode(',', $this->getValue()) : [];
8688
$exceptions = [];
8789

8890
foreach ($collection as $data) {

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class Structure implements \Magento\Config\Model\Config\Structure\SearchInterfac
4949
/**
5050
* Key that contains field type in structure array
5151
*/
52-
const TYPE_KEY = '_elementType';
52+
public const TYPE_KEY = '_elementType';
5353

5454
/**
5555
* Configuration structure represented as tree
@@ -177,7 +177,8 @@ public function getSectionList()
177177
*/
178178
public function getElement($path)
179179
{
180-
return $this->getElementByPathParts(explode('/', $path));
180+
$parts = $path !== null ? explode('/', $path) : [];
181+
return $this->getElementByPathParts($parts);
181182
}
182183

183184
/**
@@ -195,7 +196,8 @@ public function getElementByConfigPath($path)
195196
$path = array_shift($allPaths[$path]);
196197
}
197198

198-
return $this->getElementByPathParts(explode('/', $path));
199+
$parts = $path !== null ? explode('/', $path) : [];
200+
return $this->getElementByPathParts($parts);
199201
}
200202

201203
/**

app/code/Magento/Config/Model/Config/Structure/Converter.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,12 @@ protected function _convertDOMDocument(\DOMNode $root)
9494
switch ($child->nodeType) {
9595
case XML_COMMENT_NODE:
9696
continue 2;
97-
break;
9897

9998
case XML_TEXT_NODE:
100-
if ($children->length && trim($child->nodeValue, "\n ") === '') {
99+
if (
100+
$children->length
101+
&& ($child->nodeValue === null || trim($child->nodeValue, "\n ") === '')
102+
) {
101103
continue 2;
102104
}
103105
$childName = 'value';

app/code/Magento/Config/Model/Config/Structure/Element/Dependency/Field.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class Field
4545
public function __construct(array $fieldData = [], $fieldPrefix = "")
4646
{
4747
if (isset($fieldData['separator'])) {
48-
$this->_values = explode($fieldData['separator'], $fieldData['value']);
48+
$this->_values = isset($fieldData['value']) ? explode($fieldData['separator'], $fieldData['value']) : [''];
4949
} else {
5050
$this->_values = [isset($fieldData['value']) ? $fieldData['value'] : ''];
5151
}

app/code/Magento/Config/Model/Config/Structure/ElementVisibility/ConcealInProduction.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function __construct(State $state, array $configs = [], array $exemptions
8585
*/
8686
public function isHidden($path)
8787
{
88-
$path = $this->normalizePath($path);
88+
$path = $path !== null ? $this->normalizePath($path) : '';
8989
if ($this->state->getMode() === State::MODE_PRODUCTION
9090
&& preg_match('/(?<group>(?<section>.*?)\/.*?)\/.*?/', $path, $match)) {
9191
$group = $match['group'];
@@ -110,7 +110,7 @@ public function isHidden($path)
110110
*/
111111
public function isDisabled($path)
112112
{
113-
$path = $this->normalizePath($path);
113+
$path = $path !== null ? $this->normalizePath($path) : '';
114114
if ($this->state->getMode() === State::MODE_PRODUCTION) {
115115
while (true) {
116116
if (!empty($this->configs[$path])) {

app/code/Magento/Customer/Ui/Component/Listing/Address/DataProvider.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ public function addFilter(Filter $filter): void
8787
/** @var GridCollection $collection */
8888
$collection = $this->getCollection();
8989
if ($filter->getField() === 'fulltext') {
90-
$collection->addFullTextFilter(trim($filter->getValue()));
90+
$value = $filter->getValue() !== null ? trim($filter->getValue()) : '';
91+
$collection->addFullTextFilter($value);
9192
} else {
9293
$collection->addFieldToFilter(
9394
$filter->getField(),

app/code/Magento/Customer/Ui/Component/Listing/FulltextFilter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public function apply(Collection $collection, Filter $filter)
2929

3030
/** @var GridCollection $gridCollection */
3131
$gridCollection = $collection;
32-
$gridCollection->addFullTextFilter(trim($filter->getValue()));
32+
$value = $filter->getValue() !== null ? trim($filter->getValue()) : '';
33+
$gridCollection->addFullTextFilter($value);
3334
}
3435
}

app/code/Magento/Customer/view/frontend/templates/address/edit.phtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ $regionProvider = $block->getRegionProvider();
2727
<?php $_postcodeValidationClass_value = $viewModel->addressGetAttributeValidationClass('postcode'); ?>
2828
<?php $_postcodeValidationClass = $_postcodeValidationClass_value; ?>
2929
<?php $_streetValidationClass = $viewModel->addressGetAttributeValidationClass('street'); ?>
30-
<?php $_streetValidationClassNotRequired = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
30+
<?php $_streetValidationClassNotRequired = $_streetValidationClass !== null ?
31+
trim(str_replace('required-entry', '', $_streetValidationClass)) : ''; ?>
3132
<?php $_regionValidationClass = $viewModel->addressGetAttributeValidationClass('region'); ?>
3233
<form class="form-address-edit"
3334
action="<?= $escaper->escapeUrl($block->getSaveUrl()) ?>"

app/code/Magento/Customer/view/frontend/templates/form/register.phtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ $createAccountButtonViewModel = $block->getData('create_account_button_view_mode
113113
class="input-text <?= $escaper->escapeHtmlAttr($_streetValidationClass) ?>">
114114
<div class="nested">
115115
<?php
116-
$_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass));
116+
$_streetValidationClass = $_streetValidationClass !== null ?
117+
trim(str_replace('required-entry', '', $_streetValidationClass)) : '';
117118
$streetLines = $addressHelper->getStreetLines();
118119
?>
119120
<?php for ($_i = 2, $_n = $streetLines; $_i <= $_n; $_i++): ?>

0 commit comments

Comments
 (0)