Skip to content

Commit 422a871

Browse files
Karyna Tsymbalkaryna-t
authored andcommitted
Fixes to launch Magento with PHP 8.1
1 parent 0af0fba commit 422a871

File tree

9 files changed

+15
-12
lines changed

9 files changed

+15
-12
lines changed

app/code/Magento/Backend/App/DefaultPath.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ class DefaultPath implements \Magento\Framework\App\DefaultPathInterface
2424
*/
2525
public function __construct(\Magento\Backend\App\ConfigInterface $config)
2626
{
27-
$pathParts = explode('/', $config->getValue('web/default/admin'));
27+
$path = $config->getValue('web/default/admin');
28+
$pathParts = $path ? explode('/', $path) : [''];
2829

2930
$this->_parts = [
3031
'area' => isset($pathParts[0]) ? $pathParts[0] : '',

app/code/Magento/Backend/view/adminhtml/templates/widget/tabshoriz.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use Magento\Framework\View\Helper\SecureHtmlRenderer;
1919
<?php foreach ($tabs as $_tab): ?>
2020
<?php $tabId = $block->getTabId($_tab) ?>
2121
<?php $_tabClass = 'tab-item-link ' . $block->getTabClass($_tab) . ' ' .
22-
(preg_match('/\s?ajax\s?/', $_tab->getClass()) ? 'notloaded' : '') ?>
22+
(preg_match('/\s?ajax\s?/', $_tab->getClass() ?? '') ? 'notloaded' : '') ?>
2323
<?php $_tabType = (!preg_match('/\s?ajax\s?/', $_tabClass) && $block->getTabUrl($_tab) != '#') ? 'link' : '' ?>
2424
<?php $_tabHref = $block->getTabUrl($_tab) == '#' ?
2525
'#' . $tabId . '_content' :

app/code/Magento/Eav/Model/Entity/Type.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ public function getValueTablePrefix()
303303
*/
304304
public function getEntityTablePrefix()
305305
{
306-
$tablePrefix = trim($this->_data['value_table_prefix']);
306+
$tablePrefix = isset($this->_data['value_table_prefix']) ? trim($this->_data['value_table_prefix']) : '';
307307

308308
if (empty($tablePrefix)) {
309309
$tablePrefix = $this->getEntityTable();

lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,10 +1760,10 @@ public function getColumnCreateByDescribe($columnData)
17601760
if ($columnData['DEFAULT'] !== null && $type != Table::TYPE_TEXT) {
17611761
$options['default'] = $this->quote($columnData['DEFAULT']);
17621762
}
1763-
if (strlen($columnData['SCALE']) > 0) {
1763+
if (isset($columnData['SCALE']) && strlen($columnData['SCALE']) > 0) {
17641764
$options['scale'] = $columnData['SCALE'];
17651765
}
1766-
if (strlen($columnData['PRECISION']) > 0) {
1766+
if (isset($columnData['PRECISION']) && strlen($columnData['PRECISION']) > 0) {
17671767
$options['precision'] = $columnData['PRECISION'];
17681768
}
17691769

lib/internal/Magento/Framework/DB/Ddl/Table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ public function addColumn($name, $type, $size = null, $options = [], $comment =
381381
$precision = $size[0];
382382
$scale = $size[1];
383383
}
384-
} elseif (preg_match('#^(\d+),(\d+)$#', $size, $match)) {
384+
} elseif ($size && preg_match('#^(\d+),(\d+)$#', $size, $match)) {
385385
$precision = $match[1];
386386
$scale = $match[2];
387387
}

lib/internal/Magento/Framework/Filesystem/Driver/File.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,7 @@ public function getAbsolutePath($basePath, $path, $scheme = null)
962962
// check if the path given is already an absolute path containing the
963963
// basepath. so if the basepath starts at position 0 in the path, we
964964
// must not concatinate them again because path is already absolute.
965-
if (0 === strpos($path, $basePath)) {
965+
if ($path && strpos($path, $basePath) === 0) {
966966
return $this->getScheme($scheme) . $path;
967967
}
968968

@@ -997,7 +997,7 @@ public function getRelativePath($basePath, $path = null)
997997
*/
998998
protected function fixSeparator($path)
999999
{
1000-
return str_replace('\\', '/', $path);
1000+
return $path ? str_replace('\\', '/', $path) : '';
10011001
}
10021002

10031003
/**
@@ -1074,8 +1074,8 @@ public function getRealPathSafety($path)
10741074
$path
10751075
);
10761076

1077-
if (strpos($path, DIRECTORY_SEPARATOR . '.') === false) {
1078-
return rtrim($path, DIRECTORY_SEPARATOR);
1077+
if (!$path || strpos($path, DIRECTORY_SEPARATOR . '.') === false) {
1078+
return $path ? rtrim($path, DIRECTORY_SEPARATOR) : '';
10791079
}
10801080

10811081
$pathParts = explode(DIRECTORY_SEPARATOR, $path);

lib/internal/Magento/Framework/Stdlib/DateTime.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function formatDate($date, $includeTime = true)
7070
*/
7171
public function isEmptyDate($date)
7272
{
73-
return preg_replace('#[ 0:-]#', '', $date) === '';
73+
return !$date || preg_replace('#[ 0:-]#', '', $date) === '';
7474
}
7575

7676
/**

lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ public function scopeTimeStamp($scope = null)
264264
*/
265265
public function isScopeDateInInterval($scope, $dateFrom = null, $dateTo = null)
266266
{
267+
$dateFrom = $dateFrom ?: '';
268+
$dateTo = $dateTo ?: '';
267269
if (!$scope instanceof ScopeInterface) {
268270
$scope = $this->_scopeResolver->getScope($scope);
269271
}

lib/internal/Magento/Framework/Url.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ protected function _setRoutePath($data)
504504
}
505505

506506
$this->unsetData('route_path');
507-
$routePieces = explode('/', $data);
507+
$routePieces = $data ? explode('/', $data) : [''];
508508

509509
$route = array_shift($routePieces);
510510
if ('*' === $route) {

0 commit comments

Comments
 (0)