Skip to content

Commit

Permalink
[BUGFIX] Ensure BE_USER uid is always used as int
Browse files Browse the repository at this point in the history
Fix some left-over places where an int-cast
is possibly necessary to avoid PHP warnings.

Resolves: #100866
Releases: main, 12.4, 11.5
Change-Id: If9111e0c2e2de8c90a94202cf518abdbe8c987fb
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/78984
Tested-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
  • Loading branch information
liayn authored and sbuerk committed May 15, 2023
1 parent 5960854 commit 1d5195c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions typo3/sysext/core/Classes/DataHandling/DataHandler.php
Expand Up @@ -633,7 +633,7 @@ public function start($data, $cmd, $altUserObject = null)
{
// Initializing BE_USER
$this->BE_USER = is_object($altUserObject) ? $altUserObject : $GLOBALS['BE_USER'];
$this->userid = $this->BE_USER->user['uid'] ?? 0;
$this->userid = (int)($this->BE_USER->user['uid'] ?? 0);
$this->admin = $this->BE_USER->user['admin'] ?? false;

// set correlation id for each new set of data or commands
Expand Down Expand Up @@ -7911,7 +7911,7 @@ protected function getRecordHistoryStore(): RecordHistoryStore
return GeneralUtility::makeInstance(
RecordHistoryStore::class,
RecordHistoryStore::USER_BACKEND,
$this->BE_USER->user['uid'],
(int)$this->BE_USER->user['uid'],
(int)$this->BE_USER->getOriginalUserIdWhenInSwitchUserMode(),
$GLOBALS['EXEC_TIME'],
$this->BE_USER->workspace
Expand Down
Expand Up @@ -73,7 +73,7 @@ public function getPresets(int $pageId): array
while ($presetCfg = $presets->fetchAssociative()) {
$options[$presetCfg['uid']] = $presetCfg['title'] . ' [' . $presetCfg['uid'] . ']'
. ($presetCfg['public'] ? ' [Public]' : '')
. ($presetCfg['user_uid'] === $backendUser->user['uid'] ? ' [Own]' : '');
. ((int)$presetCfg['user_uid'] === (int)$backendUser->user['uid'] ? ' [Own]' : '');
}
return $options;
}
Expand Down Expand Up @@ -105,7 +105,7 @@ public function updatePreset(int $uid, array $data): void
{
$backendUser = $this->getBackendUser();
$preset = $this->getPreset($uid);
if (!($backendUser->isAdmin() || $preset['user_uid'] === $backendUser->user['uid'])) {
if (!($backendUser->isAdmin() || (int)$preset['user_uid'] === (int)$backendUser->user['uid'])) {
throw new InsufficientUserPermissionsException(
'ERROR: You were not the owner of the preset so you could not delete it.',
1604584766
Expand Down Expand Up @@ -151,7 +151,7 @@ public function deletePreset(int $uid): void
{
$backendUser = $this->getBackendUser();
$preset = $this->getPreset($uid);
if (!($backendUser->isAdmin() || $preset['user_uid'] === $backendUser->user['uid'])) {
if (!($backendUser->isAdmin() || (int)$preset['user_uid'] === (int)$backendUser->user['uid'])) {
throw new InsufficientUserPermissionsException(
'ERROR: You were not the owner of the preset so you could not delete it.',
1604564346
Expand Down
2 changes: 1 addition & 1 deletion typo3/sysext/redirects/Classes/Service/SlugService.php
Expand Up @@ -353,7 +353,7 @@ protected function getRecordHistoryStore(): RecordHistoryStore
return GeneralUtility::makeInstance(
RecordHistoryStore::class,
RecordHistoryStore::USER_BACKEND,
$backendUser->user['uid'],
(int)$backendUser->user['uid'],
(int)$backendUser->getOriginalUserIdWhenInSwitchUserMode(),
$this->context->getPropertyFromAspect('date', 'timestamp'),
$backendUser->workspace
Expand Down
Expand Up @@ -184,7 +184,7 @@ protected function storeIncomingData(ServerRequestInterface $request): void
$d = $postData['data'] ?? null;
$columns = $GLOBALS['TYPO3_USER_SETTINGS']['columns'];
$backendUser = $this->getBackendUser();
$beUserId = $backendUser->user['uid'];
$beUserId = (int)$backendUser->user['uid'];
$storeRec = [];
$doSaveData = false;
$fieldList = $this->getFieldsFromShowItem();
Expand Down Expand Up @@ -519,7 +519,7 @@ class="form-check-input"
case 'avatar':
// Get current avatar image
$html = '';
$avatarFileUid = $this->getAvatarFileUid($backendUser->user['uid']);
$avatarFileUid = $this->getAvatarFileUid((int)$backendUser->user['uid']);

if ($avatarFileUid) {
$defaultAvatarProvider = GeneralUtility::makeInstance(DefaultAvatarProvider::class);
Expand Down

0 comments on commit 1d5195c

Please sign in to comment.