Commit 3159911b authored by crell's avatar crell Committed by Richard Haeser
Browse files

[BUGFIX] Fix still more undefined variables

Manual testing found a bunch more cases of undefined variables that
need to be addressed.

Resolves: #94057
Releases: master
Change-Id: I0f602d2de5fcfdc8b41545eafacc5ff79bbfdf86
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69393


Tested-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Richard Haeser's avatarRichard Haeser <richard@richardhaeser.com>
Reviewed-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Reviewed-by: Richard Haeser's avatarRichard Haeser <richard@richardhaeser.com>
parent 1983cdb5
......@@ -53,7 +53,7 @@ class UserFunctions
public function getRouteTitle(array &$parameters): void
{
$record = $parameters['row'];
if ($record['type'][0] === 'uri') {
if (($record['type'][0] ?? false) === 'uri') {
$parameters['title'] = sprintf(
'%s %s %s',
$record['route'],
......@@ -74,7 +74,7 @@ class UserFunctions
$record = $parameters['row'];
$format = '%s: %s';
$arguments = [$record['errorCode']];
switch ($record['errorHandler'][0]) {
switch ($record['errorHandler'][0] ?? false) {
case 'Fluid':
$arguments[] = $record['errorFluidTemplate'];
break;
......@@ -85,7 +85,7 @@ class UserFunctions
$arguments[] = $record['errorPhpClassFQCN'];
break;
default:
$arguments[] = $record['errorHandler'][0];
$arguments[] = $record['errorHandler'][0] ?? '';
}
$parameters['title'] = sprintf($format, ...$arguments);
}
......
......@@ -292,7 +292,7 @@ class PageProvider extends RecordProvider
return false;
}
if (isset($GLOBALS['TCA'][$this->table]['ctrl']['languageField'])
&& !in_array($this->record[$GLOBALS['TCA'][$this->table]['ctrl']['languageField']], [0, -1])
&& !in_array($this->record[$GLOBALS['TCA'][$this->table]['ctrl']['languageField']] ?? false, [0, -1])
) {
return false;
}
......@@ -345,7 +345,7 @@ class PageProvider extends RecordProvider
return false;
}
if (isset($GLOBALS['TCA'][$this->table]['ctrl']['languageField'])
&& !in_array($this->record[$GLOBALS['TCA'][$this->table]['ctrl']['languageField']], [0, -1])
&& !in_array($this->record[$GLOBALS['TCA'][$this->table]['ctrl']['languageField']] ?? false, [0, -1])
) {
return false;
}
......@@ -365,7 +365,7 @@ class PageProvider extends RecordProvider
return false;
}
if (isset($GLOBALS['TCA'][$this->table]['ctrl']['languageField'])
&& !in_array($this->record[$GLOBALS['TCA'][$this->table]['ctrl']['languageField']], [0, -1])
&& !in_array($this->record[$GLOBALS['TCA'][$this->table]['ctrl']['languageField']] ?? false, [0, -1])
) {
return false;
}
......@@ -530,13 +530,13 @@ class PageProvider extends RecordProvider
if ($itemName === 'pagesSort') {
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$attributes += [
'data-pages-sort-url' => (string)$uriBuilder->buildUriFromRoute('pages_sort', ['id' => $this->record['uid']]),
'data-pages-sort-url' => (string)$uriBuilder->buildUriFromRoute('pages_sort', ['id' => $this->record['uid'] ?? null]),
];
}
if ($itemName === 'pagesNewMultiple') {
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$attributes += [
'data-pages-new-multiple-url' => (string)$uriBuilder->buildUriFromRoute('pages_new', ['id' => $this->record['uid']]),
'data-pages-new-multiple-url' => (string)$uriBuilder->buildUriFromRoute('pages_new', ['id' => $this->record['uid'] ?? 0]),
];
}
if ($itemName === 'edit') {
......
......@@ -653,7 +653,7 @@ class RecordProvider extends AbstractProvider
|| $this->backendUser->check('non_exclude_fields', $this->table . ':' . $hiddenFieldName)
)
) {
return (int)$this->record[$hiddenFieldName] === (int)$value;
return (int)($this->record[$hiddenFieldName] ?? 0) === (int)$value;
}
}
return false;
......@@ -693,7 +693,7 @@ class RecordProvider extends AbstractProvider
protected function isRecordInClipboard(string $mode = ''): bool
{
$isSelected = '';
if ($this->clipboard->current === 'normal') {
if ($this->clipboard->current === 'normal' && isset($this->record['uid'])) {
$isSelected = $this->clipboard->isSelected($this->table, $this->record['uid']);
}
return $mode === '' ? !empty($isSelected) : $isSelected === $mode;
......
......@@ -1423,7 +1423,7 @@ class EditDocumentController
) {
$classNames = 't3js-editform-view';
$pagesTSconfig = BackendUtility::getPagesTSconfig($this->pageinfo['uid']);
$pagesTSconfig = BackendUtility::getPagesTSconfig($this->pageinfo['uid'] ?? 0);
if (isset($pagesTSconfig['TCEMAIN.']['preview.']['disableButtonForDokType'])) {
$excludeDokTypes = GeneralUtility::intExplode(
......@@ -1441,7 +1441,7 @@ class EditDocumentController
}
if (
!in_array((int)$this->pageinfo['doktype'], $excludeDokTypes, true)
!in_array((int)($this->pageinfo['doktype'] ?? 0), $excludeDokTypes, true)
|| isset($pagesTSconfig['TCEMAIN.']['preview.'][$this->firstEl['table'] . '.']['previewPageId'])
) {
$previewPageId = $this->getPreviewPageId();
......@@ -2516,7 +2516,7 @@ class EditDocumentController
$table = (string)key($queryParameters['edit']);
$tableTitle = $languageService->sL($GLOBALS['TCA'][$table]['ctrl']['title'] ?? '') ?: $table;
$recordId = (int)key($queryParameters['edit'][$table]);
$action = (string)$queryParameters['edit'][$table][$recordId];
$action = (string)($queryParameters['edit'][$table][$recordId] ?? '');
if ($action === 'new') {
return $languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.createNew') . ' ' . $tableTitle;
......
......@@ -105,7 +105,7 @@ class FormSlugAjaxController extends AbstractFormEngineAjaxController
$recordData[$GLOBALS['TCA'][$tableName]['ctrl']['languageField']] = $languageId;
}
if ($tableName === 'pages' && empty($recordData['is_siteroot'])) {
$recordData['is_siteroot'] = $row['is_siteroot'];
$recordData['is_siteroot'] = $row['is_siteroot'] ?? false;
}
$slug = GeneralUtility::makeInstance(SlugHelper::class, $tableName, $fieldName, $fieldConfig);
......
......@@ -109,7 +109,7 @@ class NewMultiplePagesController
$view->assign('pageUid', $pageUid);
if ($canCreateNew) {
$newPagesData = (array)$request->getParsedBody()['pages'];
$newPagesData = (array)($request->getParsedBody()['pages'] ?? []);
if (!empty($newPagesData)) {
$hasNewPagesData = true;
$afterExisting = isset($request->getParsedBody()['createInListEnd']);
......
......@@ -75,7 +75,7 @@ class SiteInlineAjaxController extends AbstractFormEngineAjaxController
$parent = $inlineStackProcessor->getStructureLevel(-1);
// Child, a record from this table should be rendered
$child = $inlineStackProcessor->getUnstableStructure();
if (MathUtility::canBeInterpretedAsInteger($child['uid'])) {
if (MathUtility::canBeInterpretedAsInteger($child['uid'] ?? false)) {
// If uid comes in, it is the id of the record neighbor record "create after"
$childVanillaUid = -1 * abs((int)$child['uid']);
} else {
......
......@@ -35,7 +35,7 @@ class DatabaseDefaultLanguagePageRow extends AbstractDatabaseRecordProvider impl
{
// $defaultLanguagePageRow end up NULL if a record added or edited on root node
$tableName = $result['tableName'];
if ($tableName === 'pages' && $result['databaseRow'][$GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']] > 0) {
if ($tableName === 'pages' && ($result['databaseRow'][$GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']] ?? 0) > 0) {
$result['defaultLanguagePageRow'] = $this->getRecordFromDatabase('pages', $result['databaseRow'][$GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']]);
}
return $result;
......
......@@ -183,7 +183,7 @@ class LiveSearch
$queryBuilder->andWhere($this->userPermissions);
}
$orderBy = $GLOBALS['TCA'][$tableName]['ctrl']['sortby'] ?: $GLOBALS['TCA'][$tableName]['ctrl']['default_sortby'];
$orderBy = $GLOBALS['TCA'][$tableName]['ctrl']['sortby'] ?? $GLOBALS['TCA'][$tableName]['ctrl']['default_sortby'];
foreach (QueryHelper::parseOrderBy((string)$orderBy) as $orderPair) {
[$fieldName, $order] = $orderPair;
$queryBuilder->addOrderBy($fieldName, $order);
......@@ -214,7 +214,7 @@ class LiveSearch
if (!is_array($row)) {
continue;
}
$onlineUid = $row['t3ver_oid'] ?: $row['uid'];
$onlineUid = ($row['t3ver_oid'] ?? false) ?: $row['uid'];
$title = 'id=' . $row['uid'] . ', pid=' . $row['pid'];
$collect[$onlineUid] = [
'id' => $tableName . ':' . $row['uid'],
......@@ -327,7 +327,7 @@ class LiveSearch
}
$fieldConfig = &$GLOBALS['TCA'][$tableName]['columns'][$fieldName]['config'];
$fieldType = $fieldConfig['type'];
$evalRules = $fieldConfig['eval'] ?: '';
$evalRules = ($fieldConfig['eval'] ?? '') ?: '';
// Check whether search should be case-sensitive or not
$searchConstraint = $queryBuilder->expr()->andX(
......@@ -338,7 +338,7 @@ class LiveSearch
)
);
if (is_array($fieldConfig['search'])) {
if (is_array($fieldConfig['search'] ?? false)) {
if (in_array('case', $fieldConfig['search'], true)) {
// Replace case insensitive default constraint
$searchConstraint = $queryBuilder->expr()->andX(
......
......@@ -598,7 +598,7 @@ class BackendUtility
}
} else {
$pageinfo = self::getRecord('pages', $id, '*', $perms_clause);
if ($pageinfo['uid'] && static::getBackendUserAuthentication()->isInWebMount($pageinfo, $perms_clause)) {
if (($pageinfo['uid'] ?? false) && static::getBackendUserAuthentication()->isInWebMount($pageinfo, $perms_clause)) {
self::workspaceOL('pages', $pageinfo);
if (is_array($pageinfo)) {
[$pageinfo['_thePath'], $pageinfo['_thePathFull']] = self::getRecordPath((int)$pageinfo['uid'], $perms_clause, 15, 1000);
......
......@@ -169,7 +169,7 @@ class BackendLogController extends ActionController
register_shutdown_function(function () use (&$reservedMemory): void {
$reservedMemory = null; // free the reserved memory
$error = error_get_last();
if (strpos($error['message'], 'Allowed memory size of') !== false) {
if (strpos($error['message'] ?? '', 'Allowed memory size of') !== false) {
$constraint = GeneralUtility::makeInstance(Constraint::class);
$this->persistConstraintInBeUserData($constraint);
}
......@@ -194,12 +194,12 @@ class BackendLogController extends ActionController
foreach ($logEntries as $entry) {
$pid = -1;
// Create array if it is not defined yet
if (!is_array($targetStructure[$pid])) {
if (!is_array($targetStructure[$pid] ?? false)) {
$targetStructure[-1] = [];
}
// Get day timestamp of log entry and create sub array if needed
$timestampDay = strtotime(strftime('%d.%m.%Y', $entry->getTstamp()) ?: '');
if (!is_array($targetStructure[$pid][$timestampDay])) {
if (!is_array($targetStructure[$pid][$timestampDay] ?? false)) {
$targetStructure[$pid][$timestampDay] = [];
}
// Add row
......
......@@ -91,19 +91,19 @@ class PagePermissionAssembler
*/
protected function setTSconfigPermissions(array $fieldArray, array $tsconfig): array
{
if ((string)$tsconfig['userid'] !== '') {
if ((string)($tsconfig['userid'] ?? '') !== '') {
$fieldArray['perms_userid'] = (int)$tsconfig['userid'];
}
if ((string)$tsconfig['groupid'] !== '') {
if ((string)($tsconfig['groupid'] ?? '') !== '') {
$fieldArray['perms_groupid'] = (int)$tsconfig['groupid'];
}
if ((string)$tsconfig['user'] !== '') {
if ((string)($tsconfig['user'] ?? '') !== '') {
$fieldArray['perms_user'] = $this->assemblePermissions($tsconfig['user']);
}
if ((string)$tsconfig['group'] !== '') {
if ((string)($tsconfig['group'] ?? '') !== '') {
$fieldArray['perms_group'] = $this->assemblePermissions($tsconfig['group']);
}
if ((string)$tsconfig['everybody'] !== '') {
if ((string)($tsconfig['everybody'] ?? '') !== '') {
$fieldArray['perms_everybody'] = $this->assemblePermissions($tsconfig['everybody']);
}
return $fieldArray;
......
......@@ -770,7 +770,7 @@ class ExtendedTemplateService extends TemplateService
$p = trim(substr($type, $m));
$reg = [];
preg_match('/\\[(.*)\\]/', $p, $reg);
$p = trim($reg[1]);
$p = trim($reg[1] ?? '');
if ($p) {
$retArr['paramstr'] = $p;
switch ($retArr['type']) {
......@@ -861,7 +861,7 @@ class ExtendedTemplateService extends TemplateService
case 'int':
case 'int+':
$additionalAttributes = '';
if ($typeDat['paramstr']) {
if ($typeDat['paramstr'] ?? false) {
$hint = ' Range: ' . $typeDat['paramstr'];
} elseif ($typeDat['type'] === 'int+') {
$hint = ' Range: 0 - ';
......@@ -935,7 +935,7 @@ class ExtendedTemplateService extends TemplateService
$p_field =
'<input type="hidden" name="' . $fN . '" value="0" />'
. '<label class="btn btn-default btn-checkbox">'
. '<input id="' . $idName . '" type="checkbox" name="' . $fN . '" value="' . ($typeDat['paramstr'] ?: 1) . '" ' . $sel . ' onClick="uFormUrl(' . $aname . ')" />'
. '<input id="' . $idName . '" type="checkbox" name="' . $fN . '" value="' . (($typeDat['paramstr'] ?? false) ?: 1) . '" ' . $sel . ' onClick="uFormUrl(' . $aname . ')" />'
. '<span class="t3-icon fa"></span>'
. '</label>';
break;
......
......@@ -260,7 +260,7 @@ class ConstantConfigurationParser
if ($catSplit[1] && isset($this->subCategories[$catSplit[1]])) {
$editableComments[$const]['subcat_name'] = $catSplit[1];
$orderIdentifier = isset($catSplit[2]) ? trim($catSplit[2]) : $counter;
$editableComments[$const]['subcat'] = $this->subCategories[$catSplit[1]][1]
$editableComments[$const]['subcat'] = ($this->subCategories[$catSplit[1]][1] ?? '')
. '/' . $catSplit[1] . '/' . $orderIdentifier . 'z';
} elseif (isset($catSplit[2])) {
$editableComments[$const]['subcat'] = 'x/' . trim($catSplit[2]) . 'z';
......
......@@ -1921,7 +1921,7 @@ class GeneralUtility
{
$currentPath = $fullDirectoryPath;
$firstCreatedPath = '';
$permissionMask = (int)octdec($GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask']);
$permissionMask = (int)octdec($GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] ?? 0);
if (!@is_dir($currentPath)) {
do {
$firstCreatedPath = $currentPath;
......
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