Commit 961a6222 authored by Oliver Bartsch's avatar Oliver Bartsch Committed by Benni Mack
Browse files

[BUGFIX] Fix PHP 8 related warnings in recordlist

This fixes "Undefined array key" warnings, triggered
in recordlist and related areas.

Resolves: #94401
Releases: master
Change-Id: I34490cd8390fc3a2d0a9a40d666e2dc5a00e3e51
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69546


Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Jochen's avatarJochen <rothjochen@gmail.com>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Jochen's avatarJochen <rothjochen@gmail.com>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent ec2b2295
......@@ -933,7 +933,7 @@ class Clipboard
*/
public function isElements()
{
return is_array($this->clipData[$this->current]['el']) && !empty($this->clipData[$this->current]['el']);
return is_array($this->clipData[$this->current]['el'] ?? null) && !empty($this->clipData[$this->current]['el']);
}
/**
......
......@@ -370,7 +370,7 @@ class ElementHistoryController
$fieldsToDisplay = array_keys($entry['newRecord']);
$languageService = $this->getLanguageService();
foreach ($fieldsToDisplay as $fN) {
if (is_array($GLOBALS['TCA'][$table]['columns'][$fN]) && $GLOBALS['TCA'][$table]['columns'][$fN]['config']['type'] !== 'passthrough') {
if (is_array($GLOBALS['TCA'][$table]['columns'][$fN] ?? null) && ($GLOBALS['TCA'][$table]['columns'][$fN]['config']['type'] ?? '') !== 'passthrough') {
// Create diff-result:
$diffres = $diffUtility->makeDiffDisplay(
BackendUtility::getProcessedValue($table, $fN, $entry['oldRecord'][$fN], 0, true),
......
......@@ -1257,7 +1257,7 @@ class BackendUtility
// Hidden
$lang = static::getLanguageService();
if ($ctrl['disabled'] ?? false) {
$out .= $row[$ctrl['disabled']] ? ' - ' . $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.hidden') : '';
$out .= ($row[$ctrl['disabled']] ?? false) ? ' - ' . $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.hidden') : '';
}
if (($ctrl['starttime'] ?? false) && ($row[$ctrl['starttime']] ?? 0) > $GLOBALS['EXEC_TIME']) {
$out .= ' - ' . $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.starttime') . ':' . self::date($row[$ctrl['starttime']]) . ' (' . self::daysUntil($row[$ctrl['starttime']]) . ' ' . $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.days') . ')';
......@@ -1306,15 +1306,15 @@ class BackendUtility
$pageTsConfig = static::getPagesTSconfig($pageId);
$label = '';
if (isset($pageTsConfig['TCEFORM.'])
&& \is_array($pageTsConfig['TCEFORM.'])
&& \is_array($pageTsConfig['TCEFORM.'][$table . '.'])
&& \is_array($pageTsConfig['TCEFORM.'][$table . '.'][$column . '.'])
&& is_array($pageTsConfig['TCEFORM.'] ?? null)
&& is_array($pageTsConfig['TCEFORM.'][$table . '.'] ?? null)
&& is_array($pageTsConfig['TCEFORM.'][$table . '.'][$column . '.'] ?? null)
) {
if (\is_array($pageTsConfig['TCEFORM.'][$table . '.'][$column . '.']['addItems.'])
if (is_array($pageTsConfig['TCEFORM.'][$table . '.'][$column . '.']['addItems.'] ?? null)
&& isset($pageTsConfig['TCEFORM.'][$table . '.'][$column . '.']['addItems.'][$key])
) {
$label = $pageTsConfig['TCEFORM.'][$table . '.'][$column . '.']['addItems.'][$key];
} elseif (\is_array($pageTsConfig['TCEFORM.'][$table . '.'][$column . '.']['altLabels.'])
} elseif (is_array($pageTsConfig['TCEFORM.'][$table . '.'][$column . '.']['altLabels.'] ?? null)
&& isset($pageTsConfig['TCEFORM.'][$table . '.'][$column . '.']['altLabels.'][$key])
) {
$label = $pageTsConfig['TCEFORM.'][$table . '.'][$column . '.']['altLabels.'][$key];
......@@ -1678,7 +1678,7 @@ class BackendUtility
// Add additional where clause if foreign_match_fields are defined
$foreignMatchFields = [];
if (is_array($theColConf['foreign_match_fields'])) {
if (is_array($theColConf['foreign_match_fields'] ?? false)) {
$foreignMatchFields = $theColConf['foreign_match_fields'];
}
......
......@@ -1858,7 +1858,7 @@ class TypoScriptFrontendController implements LoggerAwareInterface
// No cache
// Set $this->no_cache TRUE if the config.no_cache value is set!
if ($this->config['config']['no_cache']) {
if ($this->config['config']['no_cache'] ?? false) {
$this->set_no_cache('config.no_cache is set', true);
}
......
......@@ -1044,7 +1044,7 @@ class RequestHandler implements RequestHandlerInterface
if (!$isInPreviewMode || $controller->doWorkspacePreview() || ($controller->config['config']['disablePreviewNotification'] ?? false)) {
return;
}
if ($controller->config['config']['message_preview']) {
if ($controller->config['config']['message_preview'] ?? '') {
$message = $controller->config['config']['message_preview'];
} else {
$label = $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_tsfe.xlf:preview');
......
......@@ -57,17 +57,17 @@ class PageLinkHandler extends AbstractLinkHandler implements LinkHandlerInterfac
*/
public function canHandleLink(array $linkParts)
{
if (!$linkParts['url']) {
if (empty($linkParts['url'] ?? '')) {
return false;
}
$data = $linkParts['url'];
// Check if the page still exists
if ((int)$data['pageuid'] > 0) {
if ((int)($data['pageuid'] ?? 0) > 0) {
$pageRow = BackendUtility::getRecordWSOL('pages', $data['pageuid']);
if (!$pageRow) {
return false;
}
} elseif ($data['pageuid'] !== 'current') {
} elseif ($data['pageuid'] ?? '' !== 'current') {
return false;
}
......
......@@ -3212,7 +3212,7 @@ class DatabaseRecordList
$languageInformation = $this->translateTools->getSystemLanguages($pageId);
$title = htmlspecialchars($languageInformation[$languageUid]['title'] ?? '');
$indent = ($table !== 'pages' && $this->isLocalized($table, $row)) ? ' style="margin-left: 16px;"' : '';
if ($languageInformation[$languageUid]['flagIcon']) {
if ($languageInformation[$languageUid]['flagIcon'] ?? false) {
return '<span title="' . $title . '"' . $indent . '>' . $this->iconFactory->getIcon(
$languageInformation[$languageUid]['flagIcon'],
Icon::SIZE_SMALL
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment