Skip to content

Commit 2ef765d

Browse files
committed
AC-1989: Fix subset of deprecated php usages
- Fixes for CR
1 parent 970c12d commit 2ef765d

File tree

6 files changed

+15
-10
lines changed

6 files changed

+15
-10
lines changed

app/code/Magento/Cron/Model/Config/Converter/Db.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ protected function _processScheduleParam(array $jobConfig, $jobName, array &$res
9292
protected function _processRunModel(array $jobConfig, $jobName, array &$result)
9393
{
9494
if (isset($jobConfig['run']) && is_array($jobConfig['run']) && array_key_exists('model', $jobConfig['run'])) {
95-
$callPath = explode('::', $jobConfig['run']['model'] ?? '');
95+
$runModel = $jobConfig['run']['model'];
96+
$callPath = $runModel ? explode('::', $runModel) : [];
9697

9798
if (empty($callPath) || empty($callPath[0]) || empty($callPath[1])) {
9899
unset($result[$jobName]['run']);

app/code/Magento/CurrencySymbol/Block/Adminhtml/System/Currency/Rate/Matrix.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ protected function _prepareRates($array)
107107

108108
foreach ($array as $key => $rate) {
109109
foreach ($rate as $code => $value) {
110-
$parts = explode('.', $value ?? '');
110+
$parts = $value !== null ? explode('.', $value) : [];
111111
if (count($parts) == 2) {
112112
$parts[1] = str_pad(rtrim($parts[1], 0), 4, '0', STR_PAD_RIGHT);
113113
$array[$key][$code] = join('.', $parts);

app/code/Magento/MediaStorage/App/Media.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,12 @@ private function createLocalCopy(): void
238238
*/
239239
private function checkMediaDirectoryChanged(): bool
240240
{
241-
return rtrim($this->mediaDirectoryPath ?? '', '/')
242-
!== rtrim($this->directoryMedia->getAbsolutePath() ?? '', '/');
241+
$isDirectoryChanged = false;
242+
if ($this->mediaDirectoryPath && $this->directoryMedia->getAbsolutePath()) {
243+
$isDirectoryChanged = rtrim($this->mediaDirectoryPath, '/')
244+
!== rtrim($this->directoryMedia->getAbsolutePath(), '/');
245+
}
246+
return $isDirectoryChanged;
243247
}
244248

245249
/**

app/code/Magento/Newsletter/Block/Adminhtml/Template/Edit.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ public function getForm()
216216
*/
217217
public function getJsTemplateName()
218218
{
219-
return addcslashes($this->getModel()->getTemplateCode() ?? '', "\"\r\n\\");
219+
$templateCode = $this->getModel()->getTemplateCode();
220+
return $templateCode ? addcslashes($templateCode, "\"\r\n\\") : '';
220221
}
221222

222223
/**

app/code/Magento/SalesRule/Model/Quote/Discount.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,10 @@ public function fetch(Quote $quote, Total $total)
293293
$amount = $total->getDiscountAmount();
294294

295295
if ($amount != 0) {
296-
$description = $total->getDiscountDescription();
296+
$description = $total->getDiscountDescription() ?? '';
297297
$result = [
298298
'code' => $this->getCode(),
299-
'title' => strlen($description ?? '') ? __('Discount (%1)', $description) : __('Discount'),
299+
'title' => strlen($description) ? __('Discount (%1)', $description) : __('Discount'),
300300
'value' => $amount
301301
];
302302
}

lib/internal/Magento/Framework/App/Utility/Files.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,9 +1661,8 @@ public function isModuleExists($moduleName)
16611661
{
16621662
$key = __METHOD__ . "/{$moduleName}";
16631663
if (!isset(self::$_cache[$key])) {
1664-
self::$_cache[$key] = file_exists(
1665-
$this->componentRegistrar->getPath(ComponentRegistrar::MODULE, $moduleName) ?? ''
1666-
);
1664+
$componentPath = $this->componentRegistrar->getPath(ComponentRegistrar::MODULE, $moduleName);
1665+
self::$_cache[$key] = $componentPath && file_exists($componentPath);
16671666
}
16681667

16691668
return self::$_cache[$key];

0 commit comments

Comments
 (0)