Commit d6651096 authored by Christian Kuhn's avatar Christian Kuhn Committed by Richard Haeser
Browse files

[TASK] PHP 8 compatibility 1/x

Change-Id: Ib1e08417a716882e8c354da92d090efdb6924dc7
Resolves: #93632
Releases: master
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/68160


Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Richard Haeser's avatarRichard Haeser <richard@richardhaeser.com>
Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Richard Haeser's avatarRichard Haeser <richard@richardhaeser.com>
parent 748870a6
......@@ -206,7 +206,9 @@ class BackendUtility
*/
public static function splitTable_Uid($str)
{
[$uid, $table] = explode('_', strrev($str), 2);
$split = explode('_', strrev($str), 2);
$uid = $split[0];
$table = $split[1] ?? '';
return [strrev($table), strrev($uid)];
}
......@@ -621,8 +623,8 @@ class BackendUtility
public static function getTCAtypeValue($table, $row)
{
$typeNum = 0;
if ($GLOBALS['TCA'][$table]) {
$field = $GLOBALS['TCA'][$table]['ctrl']['type'];
if ($GLOBALS['TCA'][$table] ?? false) {
$field = $GLOBALS['TCA'][$table]['ctrl']['type'] ?? '';
if (strpos($field, ':') !== false) {
[$pointerField, $foreignTableTypeField] = explode(':', $field);
// Get field value from database if field is not in the $row array
......@@ -652,7 +654,7 @@ class BackendUtility
}
}
} else {
$typeNum = $row[$field];
$typeNum = $row[$field] ?? 0;
}
// If that value is an empty string, set it to "0" (zero)
if (empty($typeNum)) {
......
......@@ -1018,6 +1018,10 @@ class BackendUtilityTest extends UnitTestCase
'multiple underscores' => [
'tx_runaway_domain_model_crime_scene_1234',
['tx_runaway_domain_model_crime_scene', '1234']
],
'no underscore' => [
'foo',
['', 'foo']
]
];
}
......
......@@ -204,7 +204,7 @@ abstract class AbstractUserAuthentication implements LoggerAwareInterface
*/
public $uc;
protected ?UserSession $userSession;
protected ?UserSession $userSession = null;
protected UserSessionManager $userSessionManager;
......@@ -1050,7 +1050,7 @@ abstract class AbstractUserAuthentication implements LoggerAwareInterface
*/
public function getSessionData($key)
{
return $this->userSession->get($key);
return $this->userSession ? $this->userSession->get($key) : '';
}
/**
......
......@@ -949,12 +949,14 @@ class BackendUserAuthentication extends AbstractUserAuthentication
return true;
}
// Workspace setting allows to "live edit" records of tables without versioning
if ($this->workspaceRec['live_edit'] && !BackendUtility::isTableWorkspaceEnabled($table)) {
if (($this->workspaceRec['live_edit'] ?? false)
&& !BackendUtility::isTableWorkspaceEnabled($table)
) {
return true;
}
// Always for Live workspace AND if live-edit is enabled
// and tables are completely without versioning it is ok as well.
if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS_alwaysAllowLiveEdit']) {
if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS_alwaysAllowLiveEdit'] ?? false) {
return true;
}
// If the answer is FALSE it means the only valid way to create or edit records by creating records in the workspace
......
......@@ -844,7 +844,7 @@ class DataHandler implements LoggerAwareInterface
$this->registerElementsToBeDeleted();
$this->datamap = $this->unsetElementsToBeDeleted($this->datamap);
// Editing frozen:
if ($this->BE_USER->workspace !== 0 && $this->BE_USER->workspaceRec['freeze']) {
if ($this->BE_USER->workspace !== 0 && ($this->BE_USER->workspaceRec['freeze'] ?? false)) {
$this->newlog('All editing in this workspace has been frozen!', SystemLogErrorClassification::USER_ERROR);
return false;
}
......@@ -1049,7 +1049,7 @@ class DataHandler implements LoggerAwareInterface
}
// Here the "pid" is set IF NOT the old pid was a string pointing to a place in the subst-id array.
[$tscPID] = BackendUtility::getTSCpid($table, $id, $old_pid_value ?: $fieldArray['pid']);
[$tscPID] = BackendUtility::getTSCpid($table, $id, $old_pid_value ?: ($fieldArray['pid'] ?? 0));
if ($status === 'new') {
// Apply TCAdefaults from pageTS
$fieldArray = $this->applyDefaultsForFieldArray($table, (int)$tscPID, $fieldArray);
......@@ -1274,7 +1274,7 @@ class DataHandler implements LoggerAwareInterface
// - If the field is nothing of the above and the field is configured in TCA, the fieldvalues are evaluated by ->checkValue
// If everything is OK, the field is entered into $fieldArray[]
foreach ($incomingFieldArray as $field => $fieldValue) {
if (isset($this->excludedTablesAndFields[$table . '-' . $field]) || $this->data_disableFields[$table][$id][$field]) {
if (isset($this->excludedTablesAndFields[$table . '-' . $field]) || (bool)($this->data_disableFields[$table][$id][$field] ?? false)) {
continue;
}
......@@ -1326,8 +1326,8 @@ class DataHandler implements LoggerAwareInterface
$fieldArray[$field] = $res['value'];
}
// Add the value of the original record to the diff-storage content:
if ($GLOBALS['TCA'][$table]['ctrl']['transOrigDiffSourceField']) {
$originalLanguage_diffStorage[$field] = (string)$originalLanguageRecord[$field];
if ($GLOBALS['TCA'][$table]['ctrl']['transOrigDiffSourceField'] ?? false) {
$originalLanguage_diffStorage[$field] = (string)($originalLanguageRecord[$field] ?? '');
$diffStorageFlag = true;
}
} elseif ($GLOBALS['TCA'][$table]['ctrl']['origUid'] === $field) {
......@@ -1937,11 +1937,11 @@ class DataHandler implements LoggerAwareInterface
// When values are sent as group or select they come as comma-separated values which are exploded by this function:
$valueArray = $this->checkValue_group_select_explodeSelectGroupValue($value);
// If multiple is not set, remove duplicates:
if (!$tcaFieldConf['multiple']) {
if (!($tcaFieldConf['multiple'] ?? false)) {
$valueArray = array_unique($valueArray);
}
// If an exclusive key is found, discard all others:
if ($tcaFieldConf['type'] === 'select' && $tcaFieldConf['exclusiveKeys']) {
if ($tcaFieldConf['type'] === 'select' && ($tcaFieldConf['exclusiveKeys'] ?? false)) {
$exclusiveKeys = GeneralUtility::trimExplode(',', $tcaFieldConf['exclusiveKeys']);
foreach ($valueArray as $index => $key) {
if (in_array($key, $exclusiveKeys, true)) {
......@@ -1954,7 +1954,7 @@ class DataHandler implements LoggerAwareInterface
// NOTE!!! Must check max-items of files before the later check because that check would just leave out file names if there are too many!!
$valueArray = $this->applyFiltersToValues($tcaFieldConf, $valueArray);
// Checking for select / authMode, removing elements from $valueArray if any of them is not allowed!
if ($tcaFieldConf['type'] === 'select' && $tcaFieldConf['authMode']) {
if ($tcaFieldConf['type'] === 'select' && ($tcaFieldConf['authMode'] ?? false)) {
$preCount = count($valueArray);
foreach ($valueArray as $index => $key) {
if (!$this->BE_USER->checkAuthMode($table, $field, $key, $tcaFieldConf['authMode'])) {
......@@ -1970,7 +1970,7 @@ class DataHandler implements LoggerAwareInterface
$unsetResult = false;
if (
$tcaFieldConf['type'] === 'group' && $tcaFieldConf['internal_type'] === 'db'
|| $tcaFieldConf['type'] === 'select' && ($tcaFieldConf['foreign_table'] || isset($tcaFieldConf['special']) && $tcaFieldConf['special'] === 'languages')
|| $tcaFieldConf['type'] === 'select' && (($tcaFieldConf['foreign_table'] ?? false) || isset($tcaFieldConf['special']) && $tcaFieldConf['special'] === 'languages')
) {
// check, if there is a NEW... id in the value, that should be substituted later
if (strpos($value, 'NEW') !== false) {
......@@ -2662,13 +2662,13 @@ class DataHandler implements LoggerAwareInterface
} else {
$tables = $tcaFieldConf['foreign_table'];
}
$prep = $type === 'group' ? $tcaFieldConf['prepend_tname'] : '';
$prep = $type === 'group' ? ($tcaFieldConf['prepend_tname'] ?? '') : '';
$newRelations = implode(',', $valueArray);
/** @var RelationHandler $dbAnalysis */
$dbAnalysis = $this->createRelationHandlerInstance();
$dbAnalysis->registerNonTableValues = !empty($tcaFieldConf['allowNonIdValues']);
$dbAnalysis->start($newRelations, $tables, '', 0, $currentTable, $tcaFieldConf);
if ($tcaFieldConf['MM']) {
if ($tcaFieldConf['MM'] ?? false) {
// convert submitted items to use version ids instead of live ids
// (only required for MM relations in a workspace context)
$dbAnalysis->convertItemArray();
......@@ -2923,7 +2923,7 @@ class DataHandler implements LoggerAwareInterface
public function process_cmdmap()
{
// Editing frozen:
if ($this->BE_USER->workspace !== 0 && $this->BE_USER->workspaceRec['freeze']) {
if ($this->BE_USER->workspace !== 0 && ($this->BE_USER->workspaceRec['freeze'] ?? false)) {
$this->newlog('All editing in this workspace has been frozen!', SystemLogErrorClassification::USER_ERROR);
return false;
}
......@@ -6028,7 +6028,7 @@ class DataHandler implements LoggerAwareInterface
$table = $remapAction['args'][$remapAction['pos']['table']];
$valueArray = $remapAction['args'][$remapAction['pos']['valueArray']];
$tcaFieldConf = $remapAction['args'][$remapAction['pos']['tcaFieldConf']];
$additionalData = $remapAction['additionalData'];
$additionalData = $remapAction['additionalData'] ?? [];
// The record is new and has one or more new ids (in case of versioning/workspaces):
if (strpos($id, 'NEW') !== false) {
// Replace NEW...-ID with real uid:
......@@ -6425,7 +6425,7 @@ class DataHandler implements LoggerAwareInterface
public function isTableAllowedForThisPage($page_uid, $checkTable)
{
$page_uid = (int)$page_uid;
$rootLevelSetting = (int)$GLOBALS['TCA'][$checkTable]['ctrl']['rootLevel'];
$rootLevelSetting = (int)($GLOBALS['TCA'][$checkTable]['ctrl']['rootLevel'] ?? 0);
// Check if rootLevel flag is set and we're trying to insert on rootLevel - and reversed - and that the table is not "pages" which are allowed anywhere.
if ($checkTable !== 'pages' && $rootLevelSetting !== -1 && ($rootLevelSetting xor !$page_uid)) {
return false;
......@@ -6570,7 +6570,7 @@ class DataHandler implements LoggerAwareInterface
public function tableReadOnly($table)
{
// Returns TRUE if table is readonly
return (bool)$GLOBALS['TCA'][$table]['ctrl']['readOnly'];
return (bool)($GLOBALS['TCA'][$table]['ctrl']['readOnly'] ?? false);
}
/**
......@@ -7552,7 +7552,7 @@ class DataHandler implements LoggerAwareInterface
*/
public function overrideFieldArray($table, $data)
{
if (is_array($this->overrideValues[$table])) {
if (isset($this->overrideValues[$table]) && is_array($this->overrideValues[$table])) {
$data = array_merge($data, $this->overrideValues[$table]);
}
return $data;
......@@ -7596,7 +7596,7 @@ class DataHandler implements LoggerAwareInterface
// Unset fields if stored and submitted values are equal - except the current field holds MM relations.
// In general this avoids to store superfluous data which also will be visualized in the editing history.
if (!$fieldConfiguration['MM'] && $this->isSubmittedValueEqualToStoredValue($val, $currentRecord[$col], $columnRecordTypes[$col], $isNullField)) {
if (empty($fieldConfiguration['MM']) && $this->isSubmittedValueEqualToStoredValue($val, $currentRecord[$col], $columnRecordTypes[$col], $isNullField)) {
unset($fieldArray[$col]);
} else {
if (!isset($this->mmHistoryRecords[$table . ':' . $id]['oldRecord'][$col])) {
......@@ -8011,7 +8011,8 @@ class DataHandler implements LoggerAwareInterface
*/
public function isReferenceField($conf)
{
return $conf['type'] === 'group' && $conf['internal_type'] === 'db' || $conf['type'] === 'select' && $conf['foreign_table'];
return $conf['type'] === 'group' && $conf['internal_type'] === 'db'
|| $conf['type'] === 'select' && ($conf['foreign_table'] ?? false);
}
/**
......@@ -8027,11 +8028,11 @@ class DataHandler implements LoggerAwareInterface
if ($conf['type'] !== 'inline' || !$conf['foreign_table']) {
return false;
}
if ($conf['foreign_field']) {
if ($conf['foreign_field'] ?? false) {
// The reference to the parent is stored in a pointer field in the child record
return 'field';
}
if ($conf['MM']) {
if ($conf['MM'] ?? false) {
// Regular MM intermediate table is used to store data
return 'mm';
}
......@@ -8207,7 +8208,7 @@ class DataHandler implements LoggerAwareInterface
*/
public function registerRecordIdForPageCacheClearing($table, $uid, $pid = null)
{
if (!is_array(static::$recordsToClearCacheFor[$table])) {
if (!is_array(static::$recordsToClearCacheFor[$table] ?? false)) {
static::$recordsToClearCacheFor[$table] = [];
}
static::$recordsToClearCacheFor[$table][] = (int)$uid;
......@@ -8306,7 +8307,7 @@ class DataHandler implements LoggerAwareInterface
$pageIdsThatNeedCacheFlush[] = (int)$row_tmp['uid'];
$parentPageId = (int)$row_tmp['pid'];
// Add children as well:
if ($TSConfig['clearCache_pageSiblingChildren']) {
if ($TSConfig['clearCache_pageSiblingChildren'] ?? false) {
$siblingChildrenQuery = $connectionPool->getQueryBuilderForTable('pages');
$siblingChildrenQuery->getRestrictions()
->removeAll()
......@@ -8329,7 +8330,7 @@ class DataHandler implements LoggerAwareInterface
$pageIdsThatNeedCacheFlush[] = $parentPageId;
}
// Add grand-parent as well if configured
if ($TSConfig['clearCache_pageGrandParent']) {
if ($TSConfig['clearCache_pageGrandParent'] ?? false) {
$parentQuery = $connectionPool->getQueryBuilderForTable('pages');
$parentQuery->getRestrictions()
->removeAll()
......@@ -8351,7 +8352,7 @@ class DataHandler implements LoggerAwareInterface
// For other tables than "pages", delete cache for the records "parent page".
$pageIdsThatNeedCacheFlush[] = $pageUid = (int)$this->getPID($table, $uid);
// Add the parent page as well
if ($TSConfig['clearCache_pageGrandParent']) {
if ($TSConfig['clearCache_pageGrandParent'] ?? false) {
$parentQuery = $connectionPool->getQueryBuilderForTable('pages');
$parentQuery->getRestrictions()
->removeAll()
......@@ -8636,7 +8637,8 @@ class DataHandler implements LoggerAwareInterface
foreach ($fieldArray as $field => $value) {
if (!MathUtility::canBeInterpretedAsInteger($value)
&& $GLOBALS['TCA'][$table]['columns'][$field]['config']['type'] === 'inline'
&& $GLOBALS['TCA'][$table]['columns'][$field]['config']['foreign_field']) {
&& ($GLOBALS['TCA'][$table]['columns'][$field]['config']['foreign_field'] ?? false)
) {
$result[$field] = count(GeneralUtility::trimExplode(',', $value, true));
}
}
......
......@@ -101,7 +101,7 @@ class DataMapItem
* @param array $suggestedValues
* @param array $persistedValues
* @param array $configurationFieldNames
* @return object|DataMapItem
* @return DataMapItem
*/
public static function build(
string $tableName,
......@@ -110,6 +110,7 @@ class DataMapItem
array $persistedValues,
array $configurationFieldNames
) {
/** @var DataMapItem $item */
$item = GeneralUtility::makeInstance(
static::class,
$tableName,
......@@ -119,10 +120,10 @@ class DataMapItem
$configurationFieldNames
);
$item->language = (int)($suggestedValues[$item->getLanguageFieldName()] ?? $persistedValues[$item->getLanguageFieldName()]);
$item->setParent($suggestedValues[$item->getParentFieldName()] ?? $persistedValues[$item->getParentFieldName()]);
$item->language = (int)($suggestedValues[$item->getLanguageFieldName()] ?? $persistedValues[$item->getLanguageFieldName()] ?? 0);
$item->setParent($suggestedValues[$item->getParentFieldName()] ?? $persistedValues[$item->getParentFieldName()] ?? '');
if ($item->getSourceFieldName() !== null) {
$item->setSource($suggestedValues[$item->getSourceFieldName()] ?? $persistedValues[$item->getSourceFieldName()]);
$item->setSource($suggestedValues[$item->getSourceFieldName()] ?? $persistedValues[$item->getSourceFieldName()] ?? '');
}
return $item;
......@@ -224,7 +225,7 @@ class DataMapItem
*/
public function getSourceFieldName()
{
return $this->configurationFieldNames['source'];
return $this->configurationFieldNames['source'] ?? null;
}
/**
......
......@@ -330,7 +330,7 @@ class ReferenceIndex implements LoggerAwareInterface
break;
}
// Soft references in the field
if (is_array($fieldRelations['softrefs'])) {
if (is_array($fieldRelations['softrefs']['keys'] ?? false)) {
$this->createEntryDataForSoftReferencesUsingRecord($tableName, $record, $fieldName, '', $fieldRelations['softrefs']['keys']);
}
}
......@@ -450,7 +450,7 @@ class ReferenceIndex implements LoggerAwareInterface
if ($this->shouldExcludeTableColumnFromReferenceIndex($table, $field, $onlyField) === false) {
$conf = $GLOBALS['TCA'][$table]['columns'][$field]['config'];
// Add a softref definition for link fields if the TCA does not specify one already
if ($conf['type'] === 'input' && $conf['renderType'] === 'inputLink' && empty($conf['softref'])) {
if ($conf['type'] === 'input' && isset($conf['renderType']) && $conf['renderType'] === 'inputLink' && empty($conf['softref'])) {
$conf['softref'] = 'typolink';
}
// Add DB:
......@@ -591,11 +591,11 @@ class ReferenceIndex implements LoggerAwareInterface
}
if ($this->isDbReferenceField($conf)) {
$allowedTables = $conf['type'] === 'group' ? $conf['allowed'] : $conf['foreign_table'];
if ($conf['MM_opposite_field']) {
if ($conf['MM_opposite_field'] ?? false) {
return [];
}
$dbAnalysis = GeneralUtility::makeInstance(RelationHandler::class);
$dbAnalysis->start($value, $allowedTables, $conf['MM'], $uid, $table, $conf);
$dbAnalysis->start($value, $allowedTables, $conf['MM'] ?? '', $uid, $table, $conf);
return $dbAnalysis->itemArray;
}
return false;
......@@ -847,12 +847,9 @@ class ReferenceIndex implements LoggerAwareInterface
{
return
$this->isDbReferenceField($configuration)
||
($configuration['type'] === 'input' && $configuration['renderType'] === 'inputLink') // getRelations_procDB
||
$configuration['type'] === 'flex'
||
isset($configuration['softref'])
|| ($configuration['type'] === 'input' && isset($configuration['renderType']) && $configuration['renderType'] === 'inputLink')
|| $configuration['type'] === 'flex'
|| isset($configuration['softref'])
;
}
......@@ -1165,7 +1162,9 @@ class ReferenceIndex implements LoggerAwareInterface
if (isset($this->excludedColumns[$column])) {
return true;
}
if (is_array($GLOBALS['TCA'][$tableName]['columns'][$column]) && (!$onlyColumn || $onlyColumn === $column)) {
if (is_array($GLOBALS['TCA'][$tableName]['columns'][$column] ?? false)
&& (!$onlyColumn || $onlyColumn === $column)
) {
return false;
}
return true;
......
......@@ -292,6 +292,9 @@ class RelationHandler
$deleteField = $GLOBALS['TCA'][$tName]['ctrl']['delete'] ?? false;
if ($this->checkIfDeleted && $deleteField) {
$fieldN = $tName . '.' . $deleteField;
if (!isset($this->additionalWhere[$tName])) {
$this->additionalWhere[$tName] = '';
}
$this->additionalWhere[$tName] .= ' AND ' . $fieldN . '=0';
}
}
......@@ -678,7 +681,7 @@ class RelationHandler
} else {
$oldMMs[] = $row[$uidForeign_field];
}
$oldMMs_inclUid[] = [$row['tablenames'], $row[$uidForeign_field], $row['uid']];
$oldMMs_inclUid[] = [$row['tablenames'], $row[$uidForeign_field], $row['uid'] ?? 0];
}
// For each item, insert it:
foreach ($this->itemArray as $val) {
......@@ -912,7 +915,7 @@ class RelationHandler
$foreign_table = $conf['foreign_table'];
$foreign_table_field = $conf['foreign_table_field'];
$useDeleteClause = !$this->undeleteRecord;
$foreign_match_fields = is_array($conf['foreign_match_fields']) ? $conf['foreign_match_fields'] : [];
$foreign_match_fields = is_array($conf['foreign_match_fields'] ?? false) ? $conf['foreign_match_fields'] : [];
$queryBuilder = $this->getConnectionForTableName($foreign_table)
->createQueryBuilder();
$queryBuilder->getRestrictions()
......@@ -926,7 +929,7 @@ class RelationHandler
->from($foreign_table);
// Search for $uid in foreign_field, and if we have symmetric relations, do this also on symmetric_field
if ($conf['symmetric_field']) {
if (!empty($conf['symmetric_field'])) {
$queryBuilder->where(
$queryBuilder->expr()->orX(
$queryBuilder->expr()->eq(
......@@ -970,8 +973,8 @@ class RelationHandler
// Get the correct sorting field
// Specific manual sortby for data handled by this field
$sortby = '';
if ($conf['foreign_sortby']) {
if ($conf['symmetric_sortby'] && $conf['symmetric_field']) {
if (!empty($conf['foreign_sortby'])) {
if (!empty($conf['symmetric_sortby']) && !empty($conf['symmetric_field'])) {
// Sorting depends on, from which side of the relation we're looking at it
// This requires bypassing automatic quoting and setting of the default sort direction
// @TODO: Doctrine: generalize to standard SQL to guarantee database independency
......@@ -987,13 +990,13 @@ class RelationHandler
// Regular single-side behaviour
$sortby = $conf['foreign_sortby'];
}
} elseif ($conf['foreign_default_sortby']) {
} elseif (!empty($conf['foreign_default_sortby'])) {
// Specific default sortby for data handled by this field
$sortby = $conf['foreign_default_sortby'];
} elseif ($GLOBALS['TCA'][$foreign_table]['ctrl']['sortby']) {
} elseif (!empty($GLOBALS['TCA'][$foreign_table]['ctrl']['sortby'])) {
// Manual sortby for all table records
$sortby = $GLOBALS['TCA'][$foreign_table]['ctrl']['sortby'];
} elseif ($GLOBALS['TCA'][$foreign_table]['ctrl']['default_sortby']) {
} elseif (!empty($GLOBALS['TCA'][$foreign_table]['ctrl']['default_sortby'])) {
// Default sortby for all table records
$sortby = $GLOBALS['TCA'][$foreign_table]['ctrl']['default_sortby'];
}
......@@ -1044,9 +1047,9 @@ class RelationHandler
$c = 0;
$foreign_table = $conf['foreign_table'];
$foreign_field = $conf['foreign_field'];
$symmetric_field = $conf['symmetric_field'];
$symmetric_field = $conf['symmetric_field'] ?? '';
$foreign_table_field = $conf['foreign_table_field'];
$foreign_match_fields = is_array($conf['foreign_match_fields']) ? $conf['foreign_match_fields'] : [];
$foreign_match_fields = is_array($conf['foreign_match_fields'] ?? false) ? $conf['foreign_match_fields'] : [];
// If there are table items and we have a proper $parentUid
if (MathUtility::canBeInterpretedAsInteger($parentUid) && !empty($this->tableArray)) {
// If updateToUid is not a positive integer, set it to '0', so it will be ignored
......@@ -1098,9 +1101,9 @@ class RelationHandler
// Get the correct sorting field
// Specific manual sortby for data handled by this field
$sortby = '';
if ($conf['foreign_sortby']) {
if ($conf['foreign_sortby'] ?? false) {
$sortby = $conf['foreign_sortby'];
} elseif ($GLOBALS['TCA'][$foreign_table]['ctrl']['sortby']) {
} elseif ($GLOBALS['TCA'][$foreign_table]['ctrl']['sortby'] ?? false) {
// manual sortby for all table records
$sortby = $GLOBALS['TCA'][$foreign_table]['ctrl']['sortby'];
}
......
......@@ -170,7 +170,7 @@ class ErrorHandler implements ErrorHandlerInterface, LoggerAwareInterface
// Silently catch in case an error occurs before the DI container is in place
}
// Write error message to sys_log table (ext: belog, Tools->Log)
if ($errorLevel & $GLOBALS['TYPO3_CONF_VARS']['SYS']['belogErrorReporting']) {
if ($errorLevel & $GLOBALS['TYPO3_CONF_VARS']['SYS']['belogErrorReporting'] ?? 0) {
// Silently catch in case an error occurs before a database connection exists.
try {
$this->writeLog($message, $severity);
......
......@@ -80,7 +80,7 @@ class FileReference implements FileInterface
throw new \InvalidArgumentException('Incorrect reference to original file given for FileReference.', 1300098528);
}
$this->originalFile = $this->getFileObject((int)$fileReferenceData['uid_local'], $factory);
$this->name = $fileReferenceData['name'] !== '' ? $fileReferenceData['name'] : $this->originalFile->getName();
$this->name = ($fileReferenceData['name'] ?? '') !== '' ? $fileReferenceData['name'] : $this->originalFile->getName();
}
/**
......
......@@ -438,7 +438,7 @@ class ResourceFactory implements SingletonInterface
1300086584
);
}
if (!$this->fileReferenceInstances[$uid]) {
if (!($this->fileReferenceInstances[$uid] ?? false)) {
// Fetches data in case $fileData is empty
if (empty($fileReferenceData)) {
$fileReferenceData = $this->getFileReferenceData($uid, $raw);
......@@ -483,7 +483,7 @@ class ResourceFactory implements SingletonInterface
&& ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend()
) {
$fileReferenceData = BackendUtility::getRecordWSOL('sys_file_reference', $uid);
} elseif (!$raw && is_object($GLOBALS['TSFE'])) {
} elseif (!$raw && is_object($GLOBALS['TSFE'] ?? false)) {
$fileReferenceData = $GLOBALS['TSFE']->sys_page->checkRecord('sys_file_reference', $uid);
} else {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_file_reference');
......
......@@ -2836,7 +2836,7 @@ class GeneralUtility
if (substr($path, 0, 6) === 'vfs://') {
return true;
}
$lockRootPath = $GLOBALS['TYPO3_CONF_VARS']['BE']['lockRootPath'];
$lockRootPath = $GLOBALS['TYPO3_CONF_VARS']['BE']['lockRootPath'] ?? '';
return static::isAbsPath($path) && static::validPathStr($path)
&& (
static::isFirstPartOfStr($path, Environment::getProjectPath())
......
......@@ -168,8 +168,12 @@ class PathUtility
*/
public static function basename($path)
{
$targetLocale = $GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLocale'] ?? '';
if (empty($targetLocale)) {
return basename($path);
}
$currentLocale = (string)setlocale(LC_CTYPE, '0');
setlocale(LC_CTYPE, $GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLocale']);
setlocale(LC_CTYPE, $targetLocale);
$basename = basename($path);
setlocale(LC_CTYPE, $currentLocale);
return $basename;
......@@ -189,8 +193,12 @@ class PathUtility
*/
public static function dirname($path)
{
$targetLocale = $GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLocale'] ?? '';
if (empty($targetLocale)) {
return dirname($path);
}
$currentLocale = (string)setlocale(LC_CTYPE, '0');
setlocale(LC_CTYPE, $GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLocale']);
setlocale(LC_CTYPE, $targetLocale);
$dirname = dirname($path);
setlocale(LC_CTYPE, $currentLocale);
return $dirname;
......@@ -211,8 +219,12 @@ class PathUtility
*/
public static function pathinfo($path, $options = null)
{
$targetLocale = $GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLocale'] ?? '';
if (empty($targetLocale)) {
return $options === null ? pathinfo($path) : pathinfo($path, $options);
}
$currentLocale = (string)setlocale(LC_CTYPE, '0');
setlocale(LC_CTYPE, $GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLocale']);
setlocale(LC_CTYPE, $targetLocale);
$pathinfo = $options == null ? pathinfo($path) : pathinfo($path, $options);
setlocale(LC_CTYPE, $currentLocale);
return $pathinfo;
......
......@@ -287,7 +287,7 @@ class RootlineUtility
// Ensure that only fields defined in $rootlineFields (and "addRootLineFields") are actually evaluated
if (array_key_exists($column, $pageRecord) && $this->columnHasRelationToResolve($configuration)) {
$configuration = $configuration['config'];
if ($configuration['MM']) {
if ($configuration['MM'] ?? false) {
/** @var \TYPO3\CMS\Core\Database\Re