Skip to content

Commit c4003e8

Browse files
authored
Merge pull request #7303 from magento-trigger/ph-delivery
[Platform Health] Updates for PHP8.1 and JS libs
2 parents 548ac72 + 4255f1f commit c4003e8

File tree

17 files changed

+2706
-2393
lines changed

17 files changed

+2706
-2393
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,15 @@ public function isAttributeValid($attrCode, array $attrParams, array $rowData)
205205
return $valid;
206206
}
207207

208-
if (!strlen(trim($rowData[$attrCode]))) {
208+
if ($rowData[$attrCode] === null || trim($rowData[$attrCode]) === '') {
209209
return true;
210210
}
211211

212212
if ($rowData[$attrCode] === $this->context->getEmptyAttributeValueConstant() && !$attrParams['is_required']) {
213213
return true;
214214
}
215215

216+
$valid = false;
216217
switch ($attrParams['type']) {
217218
case 'varchar':
218219
case 'text':

app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfo.php

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,39 +23,29 @@ class PersonalInfo extends \Magento\Backend\Block\Template
2323
* since his last activity. Used only if it's impossible to get such setting
2424
* from configuration.
2525
*/
26-
const DEFAULT_ONLINE_MINUTES_INTERVAL = 15;
26+
public const DEFAULT_ONLINE_MINUTES_INTERVAL = 15;
2727

2828
/**
29-
* Customer
30-
*
3129
* @var \Magento\Customer\Api\Data\CustomerInterface
3230
*/
3331
protected $customer;
3432

3533
/**
36-
* Customer log
37-
*
3834
* @var \Magento\Customer\Model\Log
3935
*/
4036
protected $customerLog;
4137

4238
/**
43-
* Customer logger
44-
*
4539
* @var \Magento\Customer\Model\Logger
4640
*/
4741
protected $customerLogger;
4842

4943
/**
50-
* Customer registry
51-
*
5244
* @var \Magento\Customer\Model\CustomerRegistry
5345
*/
5446
protected $customerRegistry;
5547

5648
/**
57-
* Account management
58-
*
5949
* @var AccountManagementInterface
6050
*/
6151
protected $accountManagement;
@@ -68,43 +58,31 @@ class PersonalInfo extends \Magento\Backend\Block\Template
6858
protected $groupRepository;
6959

7060
/**
71-
* Customer data factory
72-
*
7361
* @var \Magento\Customer\Api\Data\CustomerInterfaceFactory
7462
*/
7563
protected $customerDataFactory;
7664

7765
/**
78-
* Address helper
79-
*
8066
* @var \Magento\Customer\Helper\Address
8167
*/
8268
protected $addressHelper;
8369

8470
/**
85-
* Date time
86-
*
8771
* @var \Magento\Framework\Stdlib\DateTime
8872
*/
8973
protected $dateTime;
9074

9175
/**
92-
* Core registry
93-
*
9476
* @var \Magento\Framework\Registry
9577
*/
9678
protected $coreRegistry;
9779

9880
/**
99-
* Address mapper
100-
*
10181
* @var Mapper
10282
*/
10383
protected $addressMapper;
10484

10585
/**
106-
* Data object helper
107-
*
10886
* @var \Magento\Framework\Api\DataObjectHelper
10987
*/
11088
protected $dataObjectHelper;
@@ -439,7 +417,8 @@ public function getLastLoginDate()
439417
*/
440418
public function getStoreLastLoginDate()
441419
{
442-
$date = strtotime($this->getCustomerLog()->getLastLoginAt());
420+
$lastLogin = $this->getCustomerLog()->getLastLoginAt();
421+
$date = $lastLogin !== null ? strtotime($lastLogin) : false;
443422

444423
if ($date) {
445424
$date = $this->_localeDate->scopeDate($this->getCustomer()->getStoreId(), $date, true);

app/code/Magento/Customer/Model/Options.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function getNamePrefixOptions($store = null)
4949
{
5050
return $this->prepareNamePrefixSuffixOptions(
5151
$this->addressHelper->getConfig('prefix_options', $store),
52-
$this->addressHelper->getConfig('prefix_show', $store) == NooptreqSource::VALUE_OPTIONAL
52+
$this->addressHelper->getConfig('prefix_show', $store) === NooptreqSource::VALUE_OPTIONAL
5353
);
5454
}
5555

@@ -63,7 +63,7 @@ public function getNameSuffixOptions($store = null)
6363
{
6464
return $this->prepareNamePrefixSuffixOptions(
6565
$this->addressHelper->getConfig('suffix_options', $store),
66-
$this->addressHelper->getConfig('suffix_show', $store) == NooptreqSource::VALUE_OPTIONAL
66+
$this->addressHelper->getConfig('suffix_show', $store) === NooptreqSource::VALUE_OPTIONAL
6767
);
6868
}
6969

@@ -93,13 +93,12 @@ protected function _prepareNamePrefixSuffixOptions($options, $isOptional = false
9393
*/
9494
private function prepareNamePrefixSuffixOptions($options, $isOptional = false)
9595
{
96-
$options = trim($options);
97-
if (empty($options)) {
96+
if ($options === null || empty(trim($options))) {
9897
return false;
9998
}
100-
10199
$result = [];
102-
$options = explode(';', $options);
100+
$options = explode(';', trim($options));
101+
103102
foreach ($options as $value) {
104103
$result[] = $this->escaper->escapeHtml(trim($value)) ?: ' ';
105104
}

app/code/Magento/Dhl/Model/Carrier.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,11 +482,12 @@ public function setRequest(\Magento\Framework\DataObject $request)
482482
);
483483

484484
$shippingWeight = $request->getPackageWeight();
485+
$destStreet = $request->getDestStreet() !== null ? str_replace("\n", '', $request->getDestStreet()) : '';
485486

486487
$requestObject->setValue(sprintf('%.2f', $request->getPackageValue()))
487488
->setValueWithDiscount($request->getPackageValueWithDiscount())
488489
->setCustomsValue($request->getPackageCustomsValue())
489-
->setDestStreet($this->string->substr(str_replace("\n", '', $request->getDestStreet()), 0, 35))
490+
->setDestStreet($this->string->substr($destStreet, 0, 35))
490491
->setDestStreetLine2($request->getDestStreetLine2())
491492
->setDestCity($request->getDestCity())
492493
->setOrigCompanyName($request->getOrigCompanyName())
@@ -939,7 +940,7 @@ protected function _getDimension($dimension, $configWeightUnit = false)
939940
);
940941
}
941942

942-
return round($dimension, 3);
943+
return round((float) $dimension, 3);
943944
}
944945

945946
/**

app/code/Magento/Elasticsearch/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"magento/module-store": "*",
1313
"magento/module-catalog-inventory": "*",
1414
"magento/framework": "*",
15-
"elasticsearch/elasticsearch": "~7.15.0"
15+
"elasticsearch/elasticsearch": "~7.16.0"
1616
},
1717
"suggest": {
1818
"magento/module-config": "*"

app/code/Magento/Elasticsearch6/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"magento/module-catalog-search": "*",
99
"magento/module-search": "*",
1010
"magento/module-elasticsearch": "*",
11-
"elasticsearch/elasticsearch": "~7.15.0"
11+
"elasticsearch/elasticsearch": "~7.16.0"
1212
},
1313
"suggest": {
1414
"magento/module-config": "*"

app/code/Magento/Elasticsearch7/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"php": "~7.4.0||~8.0.0",
66
"magento/framework": "*",
77
"magento/module-elasticsearch": "*",
8-
"elasticsearch/elasticsearch": "~7.15.0",
8+
"elasticsearch/elasticsearch": "~7.16.0",
99
"magento/module-advanced-search": "*",
1010
"magento/module-catalog-search": "*"
1111
},

app/code/Magento/GoogleAnalytics/Block/Ga.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
class Ga extends \Magento\Framework\View\Element\Template
1818
{
1919
/**
20-
* Google analytics data
21-
*
2220
* @var \Magento\GoogleAnalytics\Helper\Data
2321
*/
2422
protected $_googleAnalyticsData = null;
@@ -261,8 +259,8 @@ public function getOrdersTrackingData()
261259
private function getOptPageUrl()
262260
{
263261
$optPageURL = '';
264-
$pageName = trim($this->getPageName());
265-
if ($pageName && substr($pageName, 0, 1) == '/' && strlen($pageName) > 1) {
262+
$pageName = $this->getPageName() !== null ? trim($this->getPageName()) : '';
263+
if ($pageName && substr($pageName, 0, 1) === '/' && strlen($pageName) > 1) {
266264
$optPageURL = ", '" . $this->escapeHtmlAttr($pageName, false) . "'";
267265
}
268266
return $optPageURL;

app/code/Magento/Payment/Model/Method/Cc.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ public function assignData(\Magento\Framework\DataObject $data)
286286
[
287287
'cc_type' => $additionalData->getCcType(),
288288
'cc_owner' => $additionalData->getCcOwner(),
289-
'cc_last_4' => substr($additionalData->getCcNumber(), -4),
289+
'cc_last_4' => $additionalData->getCcNumber() !== null ?
290+
substr($additionalData->getCcNumber(), -4) : '',
290291
'cc_number' => $additionalData->getCcNumber(),
291292
'cc_cid' => $additionalData->getCcCid(),
292293
'cc_exp_month' => $additionalData->getCcExpMonth(),
@@ -323,8 +324,9 @@ public function validateCcNum($ccNumber)
323324
{
324325
$cardNumber = strrev($ccNumber);
325326
$numSum = 0;
327+
$length = strlen($cardNumber);
326328

327-
for ($i = 0; $i < strlen($cardNumber); $i++) {
329+
for ($i = 0; $i < $length; $i++) {
328330
$currentNum = substr($cardNumber, $i, 1);
329331

330332
/**

app/code/Magento/Reports/Block/Adminhtml/Config/Form/Field/YtdStart.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ protected function _getElementHtml(AbstractElement $element)
2424
{
2525
$_months = [];
2626
for ($i = 1; $i <= 12; $i++) {
27-
$month = $this->_localeDate->date(mktime(null, null, null, $i, 1))
27+
$month = $this->_localeDate->date(mktime(0, 0, 0, $i, 1))
2828
->format('m');
2929
$_months[$month] = $month;
3030
}

app/code/Magento/Tax/Controller/Adminhtml/Rule/AjaxLoadRates.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Magento\Framework\App\Action\Context;
99
use Magento\Framework\App\Action\Action;
10+
use Magento\Framework\App\Action\HttpGetActionInterface;
1011
use Magento\Framework\Controller\Result\Json;
1112
use Magento\Framework\Controller\ResultFactory;
1213
use Magento\Tax\Model\Rate\Provider as RatesProvider;
@@ -17,7 +18,7 @@
1718
* Class AjaxLoadRates is intended to load existing
1819
* Tax rates as options for a select element.
1920
*/
20-
class AjaxLoadRates extends Action
21+
class AjaxLoadRates extends Action implements HttpGetActionInterface
2122
{
2223
/**
2324
* @var RatesProvider
@@ -53,7 +54,7 @@ public function __construct(
5354
public function execute()
5455
{
5556
$ratesPage = (int) $this->getRequest()->getParam('p');
56-
$ratesFilter = trim($this->getRequest()->getParam('s'));
57+
$ratesFilter = trim($this->getRequest()->getParam('s', ''));
5758

5859
try {
5960
if (!empty($ratesFilter)) {

app/code/Magento/User/Controller/Adminhtml/User/Role/SaveRole.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,27 @@ class SaveRole extends \Magento\User\Controller\Adminhtml\User\Role implements H
2525
/**
2626
* Session keys for Info form data
2727
*/
28-
const ROLE_EDIT_FORM_DATA_SESSION_KEY = 'role_edit_form_data';
28+
public const ROLE_EDIT_FORM_DATA_SESSION_KEY = 'role_edit_form_data';
2929

3030
/**
3131
* Session keys for Users form data
3232
*/
33-
const IN_ROLE_USER_FORM_DATA_SESSION_KEY = 'in_role_user_form_data';
33+
public const IN_ROLE_USER_FORM_DATA_SESSION_KEY = 'in_role_user_form_data';
3434

3535
/**
3636
* Session keys for original Users form data
3737
*/
38-
const IN_ROLE_OLD_USER_FORM_DATA_SESSION_KEY = 'in_role_old_user_form_data';
38+
public const IN_ROLE_OLD_USER_FORM_DATA_SESSION_KEY = 'in_role_old_user_form_data';
3939

4040
/**
4141
* Session keys for Use all resources flag form data
4242
*/
43-
const RESOURCE_ALL_FORM_DATA_SESSION_KEY = 'resource_all_form_data';
43+
public const RESOURCE_ALL_FORM_DATA_SESSION_KEY = 'resource_all_form_data';
4444

4545
/**
4646
* Session keys for Resource form data
4747
*/
48-
const RESOURCE_FORM_DATA_SESSION_KEY = 'resource_form_data';
48+
public const RESOURCE_FORM_DATA_SESSION_KEY = 'resource_form_data';
4949

5050
/**
5151
* @var SecurityCookie
@@ -155,7 +155,7 @@ protected function validateUser()
155155
*/
156156
private function parseRequestVariable($paramName): array
157157
{
158-
$value = $this->getRequest()->getParam($paramName, null);
158+
$value = $this->getRequest()->getParam($paramName, '');
159159
// phpcs:ignore Magento2.Functions.DiscouragedFunction
160160
parse_str($value, $value);
161161
$value = array_keys($value);

app/code/Magento/Widget/Block/Adminhtml/Widget/Options.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ protected function _addField($parameter)
172172
}
173173
} else {
174174
// phpcs:ignore Magento2.Functions.DiscouragedFunction
175-
$data['value'] = html_entity_decode($data['value']);
175+
$data['value'] = \is_string($data['value']) ? html_entity_decode($data['value']) : '';
176176
}
177177

178178
// prepare element dropdown values

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"colinmollenhour/credis": "1.12.1",
3535
"colinmollenhour/php-redis-session-abstract": "~1.4.5",
3636
"composer/composer": "^1.9 || ^2.0",
37-
"elasticsearch/elasticsearch": "~7.15.0",
37+
"elasticsearch/elasticsearch": "~7.16.0",
3838
"guzzlehttp/guzzle": "^7.3.0",
3939
"laminas/laminas-captcha": "^2.11",
4040
"laminas/laminas-code": "~4.5.0",

0 commit comments

Comments
 (0)