Commit d418d600 authored by Jochen Roth's avatar Jochen Roth Committed by Benni Mack
Browse files

[BUGFIX] Fix undefined array key warnings for frontend in PHP8

Add fallback for undefined array keys in EXT:frontend,
EXT:indexed_search, EXT:core.

This fixes frontend rendering of a basic site package
including all available content elements.

Resolves: #94546
Releases: master
Change-Id: I051f2d6d0b2278394e95af8eb26be11b3f4aa9a7
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69819


Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent 2f0c2656
......@@ -1093,7 +1093,7 @@ class DataHandler implements LoggerAwareInterface
// Removing fields which are equal to the current value:
$fieldArray = $this->compareFieldArrayWithCurrentAndUnset($table, $id, $fieldArray);
}
if ($GLOBALS['TCA'][$table]['ctrl']['tstamp'] && !empty($fieldArray)) {
if (($GLOBALS['TCA'][$table]['ctrl']['tstamp'] ?? false) && !empty($fieldArray)) {
$fieldArray[$GLOBALS['TCA'][$table]['ctrl']['tstamp']] = $GLOBALS['EXEC_TIME'];
}
// Set stage to "Editing" to make sure we restart the workflow
......@@ -6217,7 +6217,7 @@ class DataHandler implements LoggerAwareInterface
// Update in database (list of children (csv) or number of relations (foreign_field)):
if (!empty($field)) {
$fieldArray = [$field => $newValue];
if ($GLOBALS['TCA'][$table]['ctrl']['tstamp']) {
if ($GLOBALS['TCA'][$table]['ctrl']['tstamp'] ?? false) {
$fieldArray[$GLOBALS['TCA'][$table]['ctrl']['tstamp']] = $GLOBALS['EXEC_TIME'];
}
$this->updateDB($table, $id, $fieldArray);
......
......@@ -1123,7 +1123,7 @@ class PageRepository implements LoggerAwareInterface
$firstPageUid = (int)($pageRec['l10n_parent'] ?: $pageRec['uid']);
}
// Look for mount pid value plus other required circumstances:
$mount_pid = (int)$pageRec['mount_pid'];
$mount_pid = (int)($pageRec['mount_pid'] ?? 0);
if (is_array($pageRec) && (int)$pageRec['doktype'] === self::DOKTYPE_MOUNTPOINT && $mount_pid > 0 && !in_array($mount_pid, $prevMountPids, true)) {
// Get the mount point record (to verify its general existence):
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
......@@ -1327,7 +1327,7 @@ class PageRepository implements LoggerAwareInterface
$constraints = [];
if (is_array($ctrl)) {
// Delete field check:
if ($ctrl['delete']) {
if ($ctrl['delete'] ?? false) {
$constraints[] = $expressionBuilder->eq($table . '.' . $ctrl['delete'], 0);
}
if ($this->hasTableWorkspaceSupport($table)) {
......@@ -1360,7 +1360,7 @@ class PageRepository implements LoggerAwareInterface
}
// Enable fields:
if (is_array($ctrl['enablecolumns'])) {
if (is_array($ctrl['enablecolumns'] ?? false)) {
// In case of versioning-preview, enableFields are ignored (checked in
// versionOL())
if ($this->versioningWorkspaceId === 0 || !$this->hasTableWorkspaceSupport($table)) {
......@@ -1711,7 +1711,7 @@ class PageRepository implements LoggerAwareInterface
$queryBuilder->createNamedParameter($workspace, \PDO::PARAM_INT)
),
$queryBuilder->expr()->orX(
// t3ver_state=1 does not contain a t3ver_oid, and returns itself
// t3ver_state=1 does not contain a t3ver_oid, and returns itself
$queryBuilder->expr()->andX(
$queryBuilder->expr()->eq(
'uid',
......@@ -1749,7 +1749,7 @@ class PageRepository implements LoggerAwareInterface
$queryBuilder->createNamedParameter($workspace, \PDO::PARAM_INT)
),
$queryBuilder->expr()->orX(
// t3ver_state=1 does not contain a t3ver_oid, and returns itself
// t3ver_state=1 does not contain a t3ver_oid, and returns itself
$queryBuilder->expr()->andX(
$queryBuilder->expr()->eq(
'uid',
......
......@@ -98,7 +98,7 @@ class File extends AbstractFile
parent::getProperties(),
array_diff_key($this->getMetaData()->get(), parent::getProperties()),
[
'metadata_uid' => $this->getMetaData()->get()['uid']
'metadata_uid' => $this->getMetaData()->get()['uid'] ?? 0
]
);
}
......
......@@ -954,7 +954,7 @@ class TypoScriptParser
// load default TypoScript
$defaultTypoScriptKey = implode('/', $filePointerPathParts) . '/';
if (in_array($defaultTypoScriptKey, $GLOBALS['TYPO3_CONF_VARS']['FE']['contentRenderingTemplates'], true)) {
$content .= $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_' . $includeType . '.']['defaultContentRendering'];
$content .= $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_' . $includeType . '.']['defaultContentRendering'] ?? '';
}
}
}
......
......@@ -54,7 +54,7 @@ class ArrayFormFactory extends AbstractFormFactory
}
$persistenceIdentifier = $configuration['persistenceIdentifier'] ?? null;
if ($configuration['invalid'] === true) {
if ($configuration['invalid'] ?? false) {
throw new RenderingException($configuration['label'], 1529710560);
}
......
......@@ -50,9 +50,9 @@ class ContentContentObject extends AbstractContentObject
}
$conf['table'] = trim((string)$this->cObj->stdWrapValue('table', $conf ?? []));
$conf['select.'] = !empty($conf['select.']) ? $conf['select.'] : [];
$renderObjName = $conf['renderObj'] ?: '<' . $conf['table'];
$renderObjKey = $conf['renderObj'] ? 'renderObj' : '';
$renderObjConf = $conf['renderObj.'];
$renderObjName = ($conf['renderObj'] ?? false) ? $conf['renderObj'] : '<' . $conf['table'];
$renderObjKey = ($conf['renderObj'] ?? false) ? 'renderObj' : '';
$renderObjConf = $conf['renderObj.'] ?? [];
$slide = (int)$this->cObj->stdWrapValue('slide', $conf ?? []);
if (!$slide) {
$slide = 0;
......
......@@ -3121,7 +3121,7 @@ class ContentObjectRenderer implements LoggerAwareInterface
}
// return the amount of elements. No further processing
if (!empty($valArr) && ($conf['returnCount'] || $conf['returnCount.'])) {
if (!empty($valArr) && (($conf['returnCount'] ?? false) || ($conf['returnCount.'] ?? false))) {
$returnCount = (bool)$this->stdWrapValue('returnCount', $conf ?? []);
return $returnCount ? count($valArr) : 0;
}
......@@ -4159,7 +4159,7 @@ class ContentObjectRenderer implements LoggerAwareInterface
}
$sections = GeneralUtility::trimExplode('//', $field, true);
foreach ($sections as $k) {
if ((string)$this->data[$k] !== '') {
if ((string)($this->data[$k] ?? '') !== '') {
return $this->data[$k];
}
}
......@@ -4215,7 +4215,7 @@ class ContentObjectRenderer implements LoggerAwareInterface
$retVal = $this->getFileDataKey($key);
break;
case 'parameters':
$retVal = $this->parameters[$key];
$retVal = $this->parameters[$key] ?? null;
break;
case 'register':
$retVal = $tsfe->register[$key] ?? null;
......@@ -5842,7 +5842,7 @@ class ContentObjectRenderer implements LoggerAwareInterface
$error = false;
if (($conf['max'] ?? false) || ($conf['begin'] ?? false)) {
// Finding the total number of records, if used:
if (strpos(strtolower($conf['begin'] . $conf['max']), 'total') !== false) {
if (strpos(strtolower(($conf['begin'] ?? '') . $conf['max']), 'total') !== false) {
$countQueryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
$countQueryBuilder->getRestrictions()->removeAll();
$countQueryBuilder->count('*')
......@@ -5864,8 +5864,8 @@ class ContentObjectRenderer implements LoggerAwareInterface
}
if (!$error) {
$conf['begin'] = MathUtility::forceIntegerInRange((int)ceil($this->calc($conf['begin'])), 0);
$conf['max'] = MathUtility::forceIntegerInRange((int)ceil($this->calc($conf['max'])), 0);
$conf['begin'] = MathUtility::forceIntegerInRange((int)ceil($this->calc($conf['begin'] ?? '')), 0);
$conf['max'] = MathUtility::forceIntegerInRange((int)ceil($this->calc($conf['max'] ?? '')), 0);
if ($conf['begin'] > 0) {
$queryBuilder->setFirstResult($conf['begin']);
}
......
......@@ -312,7 +312,7 @@ abstract class AbstractMenuContentObject
// Set $directoryLevel so the following evaluation of the nextActive will not return
// an invalid value if .special=directory was set
$directoryLevel = 0;
if ($this->conf['special'] === 'directory') {
if (($this->conf['special'] ?? '') === 'directory') {
$value = $this->parent_cObj->stdWrapValue('value', $this->conf['special.'] ?? [], null);
if ($value === '') {
$value = $tsfe->page['uid'];
......@@ -325,7 +325,7 @@ abstract class AbstractMenuContentObject
$currentLevel = $startLevel + $this->menuNumber;
if (is_array($this->tmpl->rootLine[$currentLevel] ?? null)) {
$nextMParray = $this->MP_array;
if (empty($nextMParray) && !$this->tmpl->rootLine[$currentLevel]['_MOUNT_OL'] && $currentLevel > 0) {
if (empty($nextMParray) && !($this->tmpl->rootLine[$currentLevel]['_MOUNT_OL'] ?? false) && $currentLevel > 0) {
// Make sure to slide-down any mount point information (_MP_PARAM) to children records in the rootline
// otherwise automatic expansion will not work
$parentRecord = $this->tmpl->rootLine[$currentLevel - 1];
......@@ -334,7 +334,7 @@ abstract class AbstractMenuContentObject
}
}
// In overlay mode, add next level MPvars as well:
if ($this->tmpl->rootLine[$currentLevel]['_MOUNT_OL']) {
if ($this->tmpl->rootLine[$currentLevel]['_MOUNT_OL'] ?? false) {
$nextMParray[] = $this->tmpl->rootLine[$currentLevel]['_MP_PARAM'];
}
$this->nextActive = $this->tmpl->rootLine[$currentLevel]['uid'] .
......@@ -391,7 +391,7 @@ abstract class AbstractMenuContentObject
// Fill in the menuArr with elements that should go into the menu:
$this->menuArr = [];
foreach ($menuItems as $data) {
$isSpacerPage = (int)$data['doktype'] === PageRepository::DOKTYPE_SPACER || $data['ITEM_STATE'] === 'SPC';
$isSpacerPage = (int)($data['doktype'] ?? 0) === PageRepository::DOKTYPE_SPACER || ($data['ITEM_STATE'] ?? '') === 'SPC';
// if item is a spacer, $spacer is set
if ($this->filterMenuPages($data, $banUidArray, $isSpacerPage)) {
$c_b++;
......@@ -499,7 +499,7 @@ abstract class AbstractMenuContentObject
$additionalWhere .= $this->getDoktypeExcludeWhere();
// ... only for the FIRST level of a HMENU
if ($this->menuNumber == 1 && $this->conf['special']) {
if ($this->menuNumber == 1 && ($this->conf['special'] ?? false)) {
$value = (string)$this->parent_cObj->stdWrapValue('value', $this->conf['special.'] ?? [], null);
switch ($this->conf['special']) {
case 'userfunction':
......@@ -548,7 +548,7 @@ abstract class AbstractMenuContentObject
} elseif ($this->alternativeMenuTempArray !== []) {
// Setting $menuItems array if not level 1.
$menuItems = $this->alternativeMenuTempArray;
} elseif ($this->mconf['sectionIndex']) {
} elseif ($this->mconf['sectionIndex'] ?? false) {
$menuItems = $this->sectionIndex($alternativeSortingField);
} else {
// Default: Gets a hierarchical menu based on subpages of $this->id
......@@ -756,7 +756,7 @@ abstract class AbstractMenuContentObject
unset($row);
}
} else {
$row = $loadDB->results['pages'][$val['id']];
$row = $loadDB->results['pages'][$val['id']] ?? [];
}
// Add versioning overlay for current page (to respect workspaces)
if (isset($row) && is_array($row)) {
......@@ -788,21 +788,21 @@ abstract class AbstractMenuContentObject
$specialValue = $tsfe->page['uid'];
}
$items = GeneralUtility::intExplode(',', $specialValue);
if (MathUtility::canBeInterpretedAsInteger($this->conf['special.']['depth'])) {
if (MathUtility::canBeInterpretedAsInteger($this->conf['special.']['depth'] ?? null)) {
$depth = MathUtility::forceIntegerInRange($this->conf['special.']['depth'], 1, 20);
} else {
$depth = 20;
}
// Max number of items
$limit = MathUtility::forceIntegerInRange($this->conf['special.']['limit'], 0, 100);
$limit = MathUtility::forceIntegerInRange(($this->conf['special.']['limit'] ?? 0), 0, 100);
$maxAge = (int)$this->parent_cObj->calc($this->conf['special.']['maxAge']);
if (!$limit) {
$limit = 10;
}
// 'auto', 'manual', 'tstamp'
$mode = $this->conf['special.']['mode'];
$mode = $this->conf['special.']['mode'] ?? '';
// Get id's
$beginAtLevel = MathUtility::forceIntegerInRange($this->conf['special.']['beginAtLevel'], 0, 100);
$beginAtLevel = MathUtility::forceIntegerInRange(($this->conf['special.']['beginAtLevel'] ?? 0), 0, 100);
$id_list_arr = [];
foreach ($items as $id) {
// Exclude the current ID if beginAtLevel is > 0
......@@ -814,23 +814,8 @@ abstract class AbstractMenuContentObject
}
$id_list = implode(',', $id_list_arr);
// Get sortField (mode)
switch ($mode) {
case 'starttime':
$sortField = 'starttime';
break;
case 'lastUpdated':
case 'manual':
$sortField = 'lastUpdated';
break;
case 'tstamp':
$sortField = 'tstamp';
break;
case 'crdate':
$sortField = 'crdate';
break;
default:
$sortField = 'SYS_LASTCHANGED';
}
$sortField = $this->getMode($mode);
$extraWhere = ($this->conf['includeNotInMenu'] ? '' : ' AND pages.nav_hide=0') . $this->getDoktypeExcludeWhere();
if ($this->conf['special.']['excludeNoSearchPages']) {
$extraWhere .= ' AND pages.no_search=0';
......@@ -878,42 +863,26 @@ abstract class AbstractMenuContentObject
if (!$specialValue) {
$specialValue = $tsfe->page['uid'];
}
if ($this->conf['special.']['setKeywords'] || $this->conf['special.']['setKeywords.']) {
if (($this->conf['special.']['setKeywords'] ?? false) || ($this->conf['special.']['setKeywords.'] ?? false)) {
$kw = (string)$this->parent_cObj->stdWrapValue('setKeywords', $this->conf['special.'] ?? []);
} else {
// The page record of the 'value'.
$value_rec = $this->sys_page->getPage($specialValue);
$kfieldSrc = $this->conf['special.']['keywordsField.']['sourceField'] ?: 'keywords';
$kfieldSrc = ($this->conf['special.']['keywordsField.']['sourceField'] ?? false) ? $this->conf['special.']['keywordsField.']['sourceField'] : 'keywords';
// keywords.
$kw = trim($this->parent_cObj->keywords($value_rec[$kfieldSrc]));
}
// *'auto', 'manual', 'tstamp'
$mode = $this->conf['special.']['mode'];
switch ($mode) {
case 'starttime':
$sortField = 'starttime';
break;
case 'lastUpdated':
case 'manual':
$sortField = 'lastUpdated';
break;
case 'tstamp':
$sortField = 'tstamp';
break;
case 'crdate':
$sortField = 'crdate';
break;
default:
$sortField = 'SYS_LASTCHANGED';
}
$mode = $this->conf['special.']['mode'] ?? '';
$sortField = $this->getMode($mode);
// Depth, limit, extra where
if (MathUtility::canBeInterpretedAsInteger($this->conf['special.']['depth'])) {
if (MathUtility::canBeInterpretedAsInteger($this->conf['special.']['depth'] ?? null)) {
$depth = MathUtility::forceIntegerInRange($this->conf['special.']['depth'], 0, 20);
} else {
$depth = 20;
}
// Max number of items
$limit = MathUtility::forceIntegerInRange($this->conf['special.']['limit'], 0, 100);
$limit = MathUtility::forceIntegerInRange(($this->conf['special.']['limit'] ?? 0), 0, 100);
// Start point
$eLevel = $this->parent_cObj->getKey(
$this->parent_cObj->stdWrapValue('entryLevel', $this->conf['special.'] ?? []),
......@@ -922,7 +891,7 @@ abstract class AbstractMenuContentObject
$startUid = (int)$this->tmpl->rootLine[$eLevel]['uid'];
// Which field is for keywords
$kfield = 'keywords';
if ($this->conf['special.']['keywordsField']) {
if ($this->conf['special.']['keywordsField'] ?? false) {
[$kfield] = explode(' ', trim($this->conf['special.']['keywordsField']));
}
// If there are keywords and the startuid is present
......@@ -1189,23 +1158,23 @@ abstract class AbstractMenuContentObject
if (!$includePage) {
return false;
}
if ($data['_SAFE']) {
if ($data['_SAFE'] ?? false) {
return true;
}
// If the spacer-function is not enabled, spacers will not enter the $menuArr
if (!$this->mconf['SPC'] && $isSpacerPage) {
if (!($this->mconf['SPC'] ?? false) && $isSpacerPage) {
return false;
}
// Page may not be a 'Backend User Section' or any other excluded doktype
if (in_array((int)$data['doktype'], $this->excludedDoktypes, true)) {
if (in_array((int)($data['doktype'] ?? 0), $this->excludedDoktypes, true)) {
return false;
}
// PageID should not be banned
if (in_array((int)$data['uid'], $banUidArray, true)) {
if (in_array((int)($data['uid'] ?? 0), $banUidArray, true)) {
return false;
}
// If the page is hide in menu, but the menu does not include them do not show the page
if ($data['nav_hide'] && !$this->conf['includeNotInMenu']) {
if (($data['nav_hide'] ?? false) && !($this->conf['includeNotInMenu'] ?? false)) {
return false;
}
// Checking if a page should be shown in the menu depending on whether a translation exists or if the default language is disabled
......@@ -1318,15 +1287,15 @@ abstract class AbstractMenuContentObject
$addParams .= $this->menuArr[$key]['_ADD_GETVARS'];
$LD = $this->menuTypoLink($thePage, $mainTarget, $addParams, $typeOverride, $overrideId);
} else {
$addParams .= ($this->I['val']['additionalParams'] ?? '') . $this->menuArr[$key]['_ADD_GETVARS'];
$addParams .= ($this->I['val']['additionalParams'] ?? '') . ($this->menuArr[$key]['_ADD_GETVARS'] ?? '');
$LD = $this->menuTypoLink($this->menuArr[$key], $mainTarget, $addParams, $typeOverride, $overrideId);
}
// Override default target configuration if option is set
if ($this->menuArr[$key]['target']) {
if ($this->menuArr[$key]['target'] ?? false) {
$LD['target'] = $this->menuArr[$key]['target'];
}
// Override URL if using "External URL"
if ((int)$this->menuArr[$key]['doktype'] === PageRepository::DOKTYPE_LINK) {
if ((int)($this->menuArr[$key]['doktype'] ?? 0) === PageRepository::DOKTYPE_LINK) {
$externalUrl = (string)$this->sys_page->getExtURL($this->menuArr[$key]);
// Create link using typolink (concerning spamProtectEmailAddresses) for email links
$LD['totalURL'] = $this->parent_cObj->typoLink_URL(['parameter' => $externalUrl]);
......@@ -1341,7 +1310,7 @@ abstract class AbstractMenuContentObject
// Override url if current page is a shortcut
$shortcut = null;
if ((int)$this->menuArr[$key]['doktype'] === PageRepository::DOKTYPE_SHORTCUT && (int)$this->menuArr[$key]['shortcut_mode'] !== PageRepository::SHORTCUT_MODE_RANDOM_SUBPAGE) {
if ((int)($this->menuArr[$key]['doktype'] ?? 0) === PageRepository::DOKTYPE_SHORTCUT && (int)$this->menuArr[$key]['shortcut_mode'] !== PageRepository::SHORTCUT_MODE_RANDOM_SUBPAGE) {
$menuItem = $this->menuArr[$key];
try {
$shortcut = $tsfe->sys_page->getPageShortcut(
......@@ -1497,7 +1466,7 @@ abstract class AbstractMenuContentObject
* @param string $objSuffix Object prefix, see ->start()
* @return string HTML content of the submenu
*/
protected function subMenu($uid, $objSuffix)
protected function subMenu(int $uid, string $objSuffix)
{
// Setting alternative menu item array if _SUB_MENU has been defined in the current ->menuArr
$altArray = '';
......@@ -1516,7 +1485,7 @@ abstract class AbstractMenuContentObject
$submenu->entryLevel = $this->entryLevel + 1;
$submenu->rL_uidRegister = $this->rL_uidRegister;
$submenu->MP_array = $this->MP_array;
if ($this->menuArr[$this->I['key']]['_MP_PARAM']) {
if ($this->menuArr[$this->I['key']]['_MP_PARAM'] ?? false) {
$submenu->MP_array[] = $this->menuArr[$this->I['key']]['_MP_PARAM'];
}
// Especially scripts that build the submenu needs the parent data
......@@ -1680,19 +1649,19 @@ abstract class AbstractMenuContentObject
$natVal = (bool)$this->menuArr[$key]['isSpacer'];
break;
case 'IFSUB':
$natVal = $this->isSubMenu($this->menuArr[$key]['uid']);
$natVal = $this->isSubMenu($this->menuArr[$key]['uid'] ?? 0);
break;
case 'ACT':
$natVal = $this->isActive($this->menuArr[$key]['uid'], $this->getMPvar($key));
$natVal = $this->isActive(($this->menuArr[$key]['uid'] ?? 0), $this->getMPvar($key));
break;
case 'ACTIFSUB':
$natVal = $this->isActive($this->menuArr[$key]['uid'], $this->getMPvar($key)) && $this->isSubMenu($this->menuArr[$key]['uid']);
$natVal = $this->isActive(($this->menuArr[$key]['uid'] ?? 0), $this->getMPvar($key)) && $this->isSubMenu($this->menuArr[$key]['uid']);
break;
case 'CUR':
$natVal = $this->isCurrent($this->menuArr[$key]['uid'], $this->getMPvar($key));
$natVal = $this->isCurrent(($this->menuArr[$key]['uid'] ?? 0), $this->getMPvar($key));
break;
case 'CURIFSUB':
$natVal = $this->isCurrent($this->menuArr[$key]['uid'], $this->getMPvar($key)) && $this->isSubMenu($this->menuArr[$key]['uid']);
$natVal = $this->isCurrent(($this->menuArr[$key]['uid'] ?? 0), $this->getMPvar($key)) && $this->isSubMenu($this->menuArr[$key]['uid']);
break;
case 'USR':
$natVal = (bool)$this->menuArr[$key]['fe_group'];
......@@ -1828,7 +1797,7 @@ abstract class AbstractMenuContentObject
protected function menuTypoLink($page, $oTarget, $addParams, $typeOverride, ?int $overridePageId = null)
{
$conf = [
'parameter' => $overridePageId ?? $page['uid']
'parameter' => $overridePageId ?? $page['uid'] ?? 0
];
if (MathUtility::canBeInterpretedAsInteger($typeOverride)) {
$conf['parameter'] .= ',' . (int)$typeOverride;
......@@ -2086,4 +2055,31 @@ abstract class AbstractMenuContentObject
return null;
}
/**
* @param string $mode
* @return string
*/
private function getMode(string $mode = ''): string
{
switch ($mode) {
case 'starttime':
$sortField = 'starttime';
break;
case 'lastUpdated':
case 'manual':
$sortField = 'lastUpdated';
break;
case 'tstamp':
$sortField = 'tstamp';
break;
case 'crdate':
$sortField = 'crdate';
break;
default:
$sortField = 'SYS_LASTCHANGED';
}
return $sortField;
}
}
......@@ -70,12 +70,12 @@ class TextMenuContentObject extends AbstractMenuContentObject
$this->I = [];
$this->I['key'] = $key;
$this->I['val'] = $val;
$this->I['title'] = $this->getPageTitle($this->menuArr[$key]['title'], $this->menuArr[$key]['nav_title']);
$this->I['title'] = $this->getPageTitle(($this->menuArr[$key]['title'] ?? ''), ($this->menuArr[$key]['nav_title'] ?? ''));
$this->I['title.'] = $this->I['val']['stdWrap.'];
$this->I['title'] = $this->WMcObj->stdWrapValue('title', $this->I ?? []);
$this->I['uid'] = $this->menuArr[$key]['uid'];
$this->I['mount_pid'] = $this->menuArr[$key]['mount_pid'];
$this->I['pid'] = $this->menuArr[$key]['pid'];
$this->I['uid'] = $this->menuArr[$key]['uid'] ?? 0;
$this->I['mount_pid'] = $this->menuArr[$key]['mount_pid'] ?? 0;
$this->I['pid'] = $this->menuArr[$key]['pid'] ?? 0;
$this->I['spacer'] = $this->menuArr[$key]['isSpacer'];
// Set access key
if ($this->mconf['accessKey'] ?? false) {
......@@ -86,13 +86,13 @@ class TextMenuContentObject extends AbstractMenuContentObject
// Make link tag
$this->I['val']['ATagParams'] = $this->WMcObj->getATagParams($this->I['val']);
$this->I['val']['additionalParams'] = $this->WMcObj->stdWrapValue('additionalParams', $this->I['val']);
$this->I['linkHREF'] = $this->link((int)$key, (string)($this->I['val']['altTarget'] ?? ''), $this->mconf['forceTypeValue']);
$this->I['linkHREF'] = $this->link((int)$key, (string)($this->I['val']['altTarget'] ?? ''), ($this->mconf['forceTypeValue'] ?? ''));
if (empty($this->I['linkHREF'])) {
$this->I['val']['doNotLinkIt'] = 1;
}
// Title attribute of links:
$titleAttrValue = $this->WMcObj->stdWrapValue('ATagTitle', $this->I['val']);
$titleAttrValue .= $this->I['accessKey']['alt'];
$titleAttrValue .= $this->I['accessKey']['alt'] ?? '';
if ($titleAttrValue !== '') {
$this->I['linkHREF']['title'] = $titleAttrValue;
}
......@@ -150,7 +150,7 @@ class TextMenuContentObject extends AbstractMenuContentObject
$allWrap = $this->WMcObj->stdWrapValue('allWrap', $this->I['val']);
$this->I['theItem'] = $this->WMcObj->wrap($this->I['theItem'], $allWrap);
if ($this->I['val']['subst_elementUid'] ?? false) {
$this->I['theItem'] = str_replace('{elementUid}', $this->I['uid'], $this->I['theItem']);
$this->I['theItem'] = str_replace('{elementUid}', (string)$this->I['uid'], $this->I['theItem']);
}
// allStdWrap:
if (is_array($this->I['val']['allStdWrap.'] ?? null)) {
......
......@@ -57,6 +57,10 @@ class RecordsContentObject extends AbstractContentObject
// If the currentRecord is set, we register, that this record has invoked this function.
// It's should not be allowed to do this again then!!
if ($originalRec) {
if (!($GLOBALS['TSFE']->recordRegister[$originalRec] ?? false)) {
$GLOBALS['TSFE']->recordRegister[$originalRec] = 0;
}
++$GLOBALS['TSFE']->recordRegister[$originalRec];
}
......@@ -64,7 +68,7 @@ class RecordsContentObject extends AbstractContentObject
if ($tables !== '') {
$tablesArray = array_unique(GeneralUtility::trimExplode(',', $tables, true));
// Add tables which have a configuration (note that this may create duplicate entries)
if (is_array($conf['conf.'])) {
if (is_array($conf['conf.'] ?? false)) {
foreach ($conf['conf.'] as $key => $value) {
if (substr($key, -1) !== '.' && !in_array($key, $tablesArray)) {
$tablesArray[] = $key;
......@@ -107,10 +111,10 @@ class RecordsContentObject extends AbstractContentObject
$validPageId = $this->getPageRepository()->filterAccessiblePageIds([$row['pid']]);
$row = !empty($validPageId) ? $row : '';
}
if ($row && !$GLOBALS['TSFE']->recordRegister[$val['table'] . ':' . $val['id']]) {
$renderObjName = $conf['conf.'][$val['table']] ?: '<' . $val['table'];
$renderObjKey = $conf['conf.'][$val['table']] ? 'conf.' . $val['table'] : '';
$renderObjConf = $conf['conf.'][$val['table'] . '.'];
if ($row && !empty($val['table']) && !($GLOBALS['TSFE']->recordRegister[$val['table'] . ':' . $val['id']] ?? false)) {
$renderObjName = ($conf['conf.'][$val['table']] ?? false) ? $conf['conf.'][$val['table']] : '<' . $val['table'];
$renderObjKey = ($conf['conf.'][$val['table']] ?? false) ? 'conf.' . $val['table'] : '';
$renderObjConf = ($conf['conf.'][$val['table'] . '.'] ?? false) ? $conf['conf.'][$val['table'] . '.'] : [];
$this->cObj->currentRecordNumber++;
$cObj->parentRecordNumber = $this->cObj->currentRecordNumber;
$GLOBALS['TSFE']->currentRecord = $val['table'] . ':' . $val['id'];
...