Commit d1206ba2 authored by Oliver Klee's avatar Oliver Klee Committed by Nikita Hovratov
Browse files

[BUGFIX] Always call GU::intExplode with a string in EXT:backend

This helps avoid breakage when GeneralUtility will switch to
strict mode.

This change also prevents a whole bunch of possible invalid
array access warnings.

Resolves: #97581
Releases: main
Change-Id: Ie167d05a9d8e4c231eec5d86336405627deceb2b
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74599


Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Tested-by: Nikita Hovratov's avatarNikita Hovratov <nikita.h@live.de>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: Nikita Hovratov's avatarNikita Hovratov <nikita.h@live.de>
parent 7d1bc443
......@@ -1327,7 +1327,7 @@ class EditDocumentController
) {
$pagesTSconfig = BackendUtility::getPagesTSconfig($this->pageinfo['uid'] ?? 0);
if (isset($pagesTSconfig['TCEMAIN.']['preview.']['disableButtonForDokType'])) {
$excludeDokTypes = GeneralUtility::intExplode(',', $pagesTSconfig['TCEMAIN.']['preview.']['disableButtonForDokType'], true);
$excludeDokTypes = GeneralUtility::intExplode(',', (string)$pagesTSconfig['TCEMAIN.']['preview.']['disableButtonForDokType'], true);
} else {
// exclude sys-folders, spacers and recycler by default
$excludeDokTypes = [
......
......@@ -194,7 +194,7 @@ class NewRecordController
// Page-selection permission clause (reading)
$this->perms_clause = $beUser->getPagePermsClause(Permission::PAGE_SHOW);
// This will hide records from display - it has nothing to do with user rights!!
$pidList = $beUser->getTSConfig()['options.']['hideRecords.']['pages'] ?? '';
$pidList = (string)($beUser->getTSConfig()['options.']['hideRecords.']['pages'] ?? '');
if (!empty($pidList)) {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('pages');
......@@ -302,7 +302,7 @@ class NewRecordController
if (isset($pagesTSconfig['TCEMAIN.']['preview.']['disableButtonForDokType'])) {
$excludeDokTypes = GeneralUtility::intExplode(
',',
$pagesTSconfig['TCEMAIN.']['preview.']['disableButtonForDokType'],
(string)$pagesTSconfig['TCEMAIN.']['preview.']['disableButtonForDokType'],
true
);
} else {
......
......@@ -148,7 +148,7 @@ class TreeController
$userTsConfig = $this->getBackendUser()->getTSConfig();
$this->hiddenRecords = GeneralUtility::intExplode(
',',
$userTsConfig['options.']['hideRecords.']['pages'] ?? '',
(string)($userTsConfig['options.']['hideRecords.']['pages'] ?? ''),
true
);
$this->backgroundColors = $userTsConfig['options.']['pageTree.']['backgroundColor.'] ?? [];
......@@ -189,7 +189,7 @@ class TreeController
public function fetchReadOnlyConfigurationAction(ServerRequestInterface $request): ResponseInterface
{
$entryPoints = $request->getQueryParams()['alternativeEntryPoints'] ?? '';
$entryPoints = (string)($request->getQueryParams()['alternativeEntryPoints'] ?? '');
$entryPoints = GeneralUtility::intExplode(',', $entryPoints, true);
$additionalArguments = [
'readOnly' => 1,
......@@ -226,10 +226,10 @@ class TreeController
}
$doktypeLabelMap[$doktypeItemConfig[1]] = $doktypeItemConfig[0];
}
$doktypes = GeneralUtility::intExplode(',', $backendUser->getTSConfig()['options.']['pageTree.']['doktypesToShowInNewPageDragArea'] ?? '', true);
$doktypes = GeneralUtility::intExplode(',', (string)($backendUser->getTSConfig()['options.']['pageTree.']['doktypesToShowInNewPageDragArea'] ?? ''), true);
$doktypes = array_unique($doktypes);
$output = [];
$allowedDoktypes = GeneralUtility::intExplode(',', $backendUser->groupData['pagetypes_select'], true);
$allowedDoktypes = GeneralUtility::intExplode(',', (string)($backendUser->groupData['pagetypes_select'] ?? ''), true);
$isAdmin = $backendUser->isAdmin();
// Early return if backend user may not create any doktype
if (!$isAdmin && empty($allowedDoktypes)) {
......@@ -473,7 +473,7 @@ class TreeController
{
$backendUser = $this->getBackendUser();
$userTsConfig = $backendUser->getTSConfig();
$excludedDocumentTypes = GeneralUtility::intExplode(',', $userTsConfig['options.']['pageTree.']['excludeDoktypes'] ?? '', true);
$excludedDocumentTypes = GeneralUtility::intExplode(',', (string)($userTsConfig['options.']['pageTree.']['excludeDoktypes'] ?? ''), true);
$additionalQueryRestrictions = [];
if (!empty($excludedDocumentTypes)) {
......
......@@ -511,7 +511,7 @@ class PageLayoutController
protected function getActiveColumnsArray(PageLayoutContext $pageLayoutContext, array $tsConfig): array
{
$availableColumnPositionsFromBackendLayout = array_unique($pageLayoutContext->getBackendLayout()->getColumnPositionNumbers());
$allowedColumnPositionsByTsConfig = array_unique(GeneralUtility::intExplode(',', $tsConfig['mod.']['SHARED.']['colPos_list'] ?? '', true));
$allowedColumnPositionsByTsConfig = array_unique(GeneralUtility::intExplode(',', (string)($tsConfig['mod.']['SHARED.']['colPos_list'] ?? ''), true));
$activeColumns = $availableColumnPositionsFromBackendLayout;
if (!empty($allowedColumnPositionsByTsConfig)) {
// If there is no tsConfig colPos_list, no restriction. Else create intersection of available and allowed.
......@@ -537,7 +537,7 @@ class PageLayoutController
];
// Exclude sysfolders, spacers and recycler by default, but allow custom overrides via tsConfig
if (isset($tsConfig['TCEMAIN.']['preview.']['disableButtonForDokType'])) {
$excludeDokTypes = GeneralUtility::intExplode(',', $tsConfig['TCEMAIN.']['preview.']['disableButtonForDokType'], true);
$excludeDokTypes = GeneralUtility::intExplode(',', (string)($tsConfig['TCEMAIN.']['preview.']['disableButtonForDokType'] ?? ''), true);
}
if (
$this->currentSelectedLanguage !== -1
......
......@@ -141,7 +141,7 @@ class SuggestWizardController
$replacement['###PAGE_TSCONFIG_ID###'] = (int)$fieldTSconfig['PAGE_TSCONFIG_ID'];
}
if (isset($fieldTSconfig['PAGE_TSCONFIG_IDLIST'])) {
$replacement['###PAGE_TSCONFIG_IDLIST###'] = implode(',', GeneralUtility::intExplode(',', $fieldTSconfig['PAGE_TSCONFIG_IDLIST']));
$replacement['###PAGE_TSCONFIG_IDLIST###'] = implode(',', GeneralUtility::intExplode(',', (string)$fieldTSconfig['PAGE_TSCONFIG_IDLIST']));
}
if (isset($fieldTSconfig['PAGE_TSCONFIG_STR'])) {
$connection = $connectionPool->getConnectionForTable($fieldConfig['foreign_table']);
......
......@@ -885,7 +885,7 @@ abstract class AbstractItemProvider
return implode(',', array_map('intval', $value));
}
return implode(',', GeneralUtility::intExplode(',', $value, true));
return implode(',', GeneralUtility::intExplode(',', (string)$value, true));
}, $parsedSiteConfiguration));
$resolvedStartingPoints = $this->replaceParsedSiteConfiguration($fieldConfig['config']['treeConfig']['startingPoints'], $parsedSiteConfiguration);
// Add the resolved starting points while removing empty values
......
......@@ -66,7 +66,7 @@ class DatabaseLanguageRows implements FormDataProviderInterface
) {
$defaultLanguageKey = $result['tableName'] . ':' . (int)$result['databaseRow']['uid'];
$result['defaultLanguageDiffRow'][$defaultLanguageKey] = json_decode(
(string)($result['databaseRow'][$result['processedTca']['ctrl']['transOrigDiffSourceField']] ?? ''),
(string)$result['databaseRow'][$result['processedTca']['ctrl']['transOrigDiffSourceField']],
true
);
}
......@@ -75,7 +75,7 @@ class DatabaseLanguageRows implements FormDataProviderInterface
// @todo: Permission check if user is in "restrict ot language" is missing here.
// @todo: The TranslationConfigurationProvider is more stupid than good for us ... invent a better translation overlay api!
if (!empty($result['userTsConfig']['options.']['additionalPreviewLanguages'])) {
$additionalLanguageUids = GeneralUtility::intExplode(',', $result['userTsConfig']['options.']['additionalPreviewLanguages'], true);
$additionalLanguageUids = GeneralUtility::intExplode(',', (string)$result['userTsConfig']['options.']['additionalPreviewLanguages'], true);
$translationProvider = GeneralUtility::makeInstance(TranslationConfigurationProvider::class);
foreach ($additionalLanguageUids as $additionalLanguageUid) {
// Continue if this system language record does not exist or if 0 or -1 is requested
......
......@@ -137,7 +137,7 @@ class TcaCategory extends AbstractItemProvider implements FormDataProviderInterf
}
if (isset($pageTsConfig['startingPoints'])) {
$fieldConfig['config']['treeConfig']['startingPoints'] = implode(',', array_unique(GeneralUtility::intExplode(',', $pageTsConfig['startingPoints'])));
$fieldConfig['config']['treeConfig']['startingPoints'] = implode(',', array_unique(GeneralUtility::intExplode(',', (string)$pageTsConfig['startingPoints'])));
}
if (isset($pageTsConfig['appearance.']['expandAll'])) {
$fieldConfig['config']['treeConfig']['appearance']['expandAll'] = (bool)$pageTsConfig['appearance.']['expandAll'];
......
......@@ -71,7 +71,8 @@ class TcaSelectTreeItems extends AbstractItemProvider implements FormDataProvide
if (isset($result['pageTsConfig']['TCEFORM.'][$table . '.'][$fieldName . '.']['config.']['treeConfig.'])) {
$pageTsConfig = $result['pageTsConfig']['TCEFORM.'][$table . '.'][$fieldName . '.']['config.']['treeConfig.'];
if (isset($pageTsConfig['startingPoints'])) {
$fieldConfig['config']['treeConfig']['startingPoints'] = implode(',', array_unique(GeneralUtility::intExplode(',', $pageTsConfig['startingPoints'])));
$fieldConfig['config']['treeConfig']['startingPoints']
= implode(',', array_unique(GeneralUtility::intExplode(',', (string)$pageTsConfig['startingPoints'])));
}
if (isset($pageTsConfig['appearance.']['expandAll'])) {
$fieldConfig['config']['treeConfig']['appearance']['expandAll'] = (bool)$pageTsConfig['appearance.']['expandAll'];
......
......@@ -108,7 +108,7 @@ class SuggestWizardDefaultReceiver
$this->config = $config;
// get a list of all the pages that should be looked on
if (isset($config['pidList'])) {
$pageIds = GeneralUtility::intExplode(',', $config['pidList'], true);
$pageIds = GeneralUtility::intExplode(',', (string)$config['pidList'], true);
$depth = (int)($config['pidDepth'] ?? 0);
$availablePageIds = [];
foreach ($pageIds as $pageId) {
......
......@@ -38,7 +38,7 @@ class BrowseTreeView extends AbstractTreeView
$backendUser = $this->getBackendUser();
// This will hide records from display - it has nothing to do with user rights!!
$clauseExcludePidList = '';
$pidList = $backendUser->getTSConfig()['options.']['hideRecords.']['pages'] ?? '';
$pidList = (string)($backendUser->getTSConfig()['options.']['hideRecords.']['pages'] ?? '');
if (!empty($pidList)) {
if ($pidList = implode(',', GeneralUtility::intExplode(',', $pidList))) {
$clauseExcludePidList = ' AND pages.uid NOT IN (' . $pidList . ')';
......
......@@ -1176,7 +1176,7 @@ class BackendUtility
}
if ($row['fe_group']) {
$fe_groups = [];
foreach (GeneralUtility::intExplode(',', $row['fe_group']) as $fe_group) {
foreach (GeneralUtility::intExplode(',', (string)$row['fe_group']) as $fe_group) {
if ($fe_group < 0) {
$fe_groups[] = $lang->sL(self::getLabelFromItemlist('pages', 'fe_group', (string)$fe_group));
} else {
......
......@@ -263,7 +263,7 @@ class PageLayoutView implements LoggerAwareInterface
*/
protected function getSelectedLanguages(): array
{
$langList = $this->tt_contentConfig['sys_language_uid'];
$langList = (string)($this->tt_contentConfig['sys_language_uid'] ?? '');
if ($this->tt_contentConfig['languageMode']) {
if ($this->tt_contentConfig['languageColsPointer']) {
$langList = '0,' . $this->tt_contentConfig['languageColsPointer'];
......
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