Commit 59aa5c0b authored by Oliver Klee's avatar Oliver Klee Committed by Stefan Bürk
Browse files

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

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: #97582
Relates: #97580
Releases: main
Change-Id: I950d64fcb2f16b5044eeff465c85b4022525ceb6
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74863

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
parent 85373145
......@@ -1004,7 +1004,7 @@ class BackendUserAuthentication extends AbstractUserAuthentication
return;
}
if ($append) {
$currentWebMounts = GeneralUtility::intExplode(',', $this->groupData['webmounts']);
$currentWebMounts = GeneralUtility::intExplode(',', (string)($this->groupData['webmounts'] ?? ''));
$mountPointUids = array_merge($currentWebMounts, $mountPointUids);
}
$this->groupData['webmounts'] = implode(',', array_unique($mountPointUids));
......@@ -1344,11 +1344,11 @@ TCAdefaults.sys_note.email = ' . $this->user['email'];
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
// Processing file mounts (both from the user and the groups)
$fileMounts = array_unique(GeneralUtility::intExplode(',', $this->groupData['filemounts'] ?? '', true));
$fileMounts = array_unique(GeneralUtility::intExplode(',', (string)($this->groupData['filemounts'] ?? ''), true));
// Limit file mounts if set in workspace record
if ($this->workspace > 0 && !empty($this->workspaceRec['file_mountpoints'])) {
$workspaceFileMounts = GeneralUtility::intExplode(',', $this->workspaceRec['file_mountpoints'], true);
$workspaceFileMounts = GeneralUtility::intExplode(',', (string)$this->workspaceRec['file_mountpoints'], true);
$fileMounts = array_intersect($fileMounts, $workspaceFileMounts);
}
......@@ -1756,7 +1756,7 @@ TCAdefaults.sys_note.email = ' . $this->user['email'];
// but make sure they match against the users' DB mounts
$workspaceWebMounts = GeneralUtility::intExplode(',', $dbMountpoints);
$webMountsOfUser = GeneralUtility::intExplode(',', $this->groupData['webmounts']);
$webMountsOfUser = GeneralUtility::intExplode(',', (string)($this->groupData['webmounts'] ?? ''));
$webMountsOfUser = array_combine($webMountsOfUser, $webMountsOfUser) ?: [];
$entryPointRootLineUids = [];
......
......@@ -58,7 +58,7 @@ class GroupResolver
public function resolveGroupsForUser(array $userRecord, string $sourceTable): array
{
$this->sourceTable = $sourceTable;
$originalGroupIds = GeneralUtility::intExplode(',', $userRecord[$this->sourceField] ?? '', true);
$originalGroupIds = GeneralUtility::intExplode(',', (string)($userRecord[$this->sourceField] ?? ''), true);
$resolvedGroups = $this->fetchGroupsRecursive($originalGroupIds);
$event = $this->eventDispatcher->dispatch(new AfterGroupsResolvedEvent($sourceTable, $resolvedGroups, $originalGroupIds, $userRecord));
return $event->getGroups();
......@@ -88,7 +88,7 @@ class GroupResolver
continue;
}
// Add sub groups first
$subgroupIds = GeneralUtility::intExplode(',', $foundGroups[$groupId][$this->recursiveSourceField] ?? '', true);
$subgroupIds = GeneralUtility::intExplode(',', (string)($foundGroups[$groupId][$this->recursiveSourceField] ?? ''), true);
if (!empty($subgroupIds)) {
$subgroups = $this->fetchGroupsRecursive($subgroupIds, array_merge($processedGroupIds, [$groupId]));
$validGroups = array_merge($validGroups, $subgroups);
......
......@@ -1062,7 +1062,7 @@ class PageRepository implements LoggerAwareInterface
if ((int)$page['doktype'] === self::DOKTYPE_SHORTCUT) {
if (!in_array($page['uid'], $pageLog) && $iteration > 0) {
$pageLog[] = $page['uid'];
$page = $this->getPageShortcut($page['shortcut'], $page['shortcut_mode'], $page['uid'], $iteration - 1, $pageLog, $disableGroupCheck);
$page = $this->getPageShortcut((string)$page['shortcut'], $page['shortcut_mode'], $page['uid'], $iteration - 1, $pageLog, $disableGroupCheck);
} else {
$pageLog[] = $page['uid'];
$this->logger->error('Page shortcuts were looping in uids {uids}', ['uids' => implode(', ', array_values($pageLog))]);
......
......@@ -473,7 +473,7 @@ class GraphicalFunctions
{
$cpW = imagesx($cpImg);
$cpH = imagesy($cpImg);
$tile = GeneralUtility::intExplode(',', $conf['tile'] ?? '');
$tile = GeneralUtility::intExplode(',', (string)($conf['tile'] ?? ''));
$tile[0] = MathUtility::forceIntegerInRange($tile[0], 1, 20);
$tile[1] = MathUtility::forceIntegerInRange($tile[1] ?? 0, 1, 20);
$cpOff = $this->objPosition($conf, $workArea, [$cpW * $tile[0], $cpH * $tile[1]]);
......@@ -715,7 +715,7 @@ class GraphicalFunctions
$result[0] = 0;
$result[1] = 0;
}
$result = $this->applyOffset($result, GeneralUtility::intExplode(',', $conf['offset'] ?? ''));
$result = $this->applyOffset($result, GeneralUtility::intExplode(',', (string)($conf['offset'] ?? '')));
$result = $this->applyOffset($result, $workArea);
return $result;
}
......@@ -1079,7 +1079,7 @@ class GraphicalFunctions
// Initialize range:
$ranges = GeneralUtility::trimExplode(',', $cfg['value'], true);
foreach ($ranges as $i => $rangeDef) {
$ranges[$i] = GeneralUtility::intExplode('-', (string)$ranges[$i]);
$ranges[$i] = GeneralUtility::intExplode('-', $rangeDef);
if (!isset($ranges[$i][1])) {
$ranges[$i][1] = $ranges[$i][0];
}
......@@ -1385,7 +1385,7 @@ class GraphicalFunctions
{
$conf['color'] = $conf['highColor'];
$this->makeShadow($im, $conf, $workArea, $txtConf);
$newOffset = GeneralUtility::intExplode(',', $conf['offset']);
$newOffset = GeneralUtility::intExplode(',', (string)($conf['offset'] ?? ''));
$newOffset[0] *= -1;
$newOffset[1] *= -1;
$conf['offset'] = implode(',', $newOffset);
......@@ -1407,7 +1407,7 @@ class GraphicalFunctions
*/
public function makeShadow(&$im, $conf, $workArea, $txtConf)
{
$workArea = $this->applyOffset($workArea, GeneralUtility::intExplode(',', $conf['offset']));
$workArea = $this->applyOffset($workArea, GeneralUtility::intExplode(',', (string)($conf['offset'])));
$blurRate = MathUtility::forceIntegerInRange((int)$conf['blur'], 0, 99);
// No effects if ImageMagick ver. 5+
if (!$blurRate || !$this->processorEffectsEnabled) {
......@@ -2056,7 +2056,7 @@ class GraphicalFunctions
default:
$result[1] = 0;
}
$result = $this->applyOffset($result, GeneralUtility::intExplode(',', $conf['offset'] ?? ''));
$result = $this->applyOffset($result, GeneralUtility::intExplode(',', (string)($conf['offset'] ?? '')));
$result = $this->applyOffset($result, $workArea);
return $result;
}
......
......@@ -62,7 +62,7 @@ class FileExtensionFilter
if (empty($value)) {
continue;
}
$parts = GeneralUtility::revExplode('_', $value, 2);
$parts = GeneralUtility::revExplode('_', (string)$value, 2);
$fileReferenceUid = $parts[count($parts) - 1];
try {
$fileReference = GeneralUtility::makeInstance(ResourceFactory::class)->getFileReferenceObject($fileReferenceUid);
......
......@@ -407,7 +407,7 @@ class PageRouter implements RouterInterface
$prefixesToRemove = [];
$slugPrefixesToAdd = [];
foreach ($mountPointPairs as $mountPointPair) {
[$mountRoot, $mountedPage] = GeneralUtility::intExplode('-', $mountPointPair);
[$mountRoot, $mountedPage] = GeneralUtility::intExplode('-', (string)$mountPointPair);
$mountPageInformation = $pageRepository->getMountPointInfo($mountedPage);
if ($mountPageInformation) {
if ($pageId === $mountedPage) {
......
......@@ -150,7 +150,7 @@ class NullSite implements SiteInterface
$pageTs = BackendUtility::getPagesTSconfig((int)$pageId);
$pageTs = $pageTs['mod.']['SHARED.'] ?? [];
$disabledLanguages = GeneralUtility::intExplode(',', $pageTs['disableLanguages'] ?? '', true);
$disabledLanguages = GeneralUtility::intExplode(',', (string)($pageTs['disableLanguages'] ?? ''), true);
// Do not add the ones that are not allowed by the user
foreach ($this->languages as $language) {
if ($user->checkLanguageAccess($language->getLanguageId()) && !in_array($language->getLanguageId(), $disabledLanguages, true)) {
......
......@@ -463,7 +463,7 @@ class DatabaseTreeDataProvider extends AbstractTableConfigurationTreeDataProvide
{
$relatedUids = [];
$uid = $row['uid'];
$value = $row[$this->getLookupField()];
$value = (string)$row[$this->getLookupField()];
switch ((string)$this->columnConfiguration['type']) {
case 'inline':
// Intentional fall-through
......
......@@ -89,7 +89,7 @@ class TreeDataProviderFactory
$treeConfiguration = $tcaConfiguration['treeConfig'];
if (isset($treeConfiguration['startingPoints'])) {
$dataProvider->setStartingPoints(array_unique(GeneralUtility::intExplode(',', $treeConfiguration['startingPoints'])));
$dataProvider->setStartingPoints(array_unique(GeneralUtility::intExplode(',', (string)$treeConfiguration['startingPoints'])));
}
if (isset($treeConfiguration['appearance']['expandAll'])) {
$dataProvider->setExpandAll((bool)$treeConfiguration['appearance']['expandAll']);
......
......@@ -619,10 +619,11 @@ class TemplateService
}
// Include "Based On" sys_templates:
// 'basedOn' is a list of templates to include
if (trim($row['basedOn'] ?? '')) {
$basedOn = trim($row['basedOn'] ?? '');
if ($basedOn !== '') {
// Normal Operation, which is to include the "based-on" sys_templates,
// if they are not already included, and maintaining the sorting of the templates
$basedOnIds = GeneralUtility::intExplode(',', $row['basedOn'], true);
$basedOnIds = GeneralUtility::intExplode(',', $basedOn, true);
// skip template if it's already included
foreach ($basedOnIds as $key => $basedOnId) {
if (GeneralUtility::inList($idList, 'sys_' . $basedOnId)) {
......
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