Skip to content
Snippets Groups Projects
Commit 42d71b44 authored by Garvin Hicking's avatar Garvin Hicking Committed by Stefan Bürk
Browse files

[BUGFIX] Prevent PHP array access errors on invalid shortcut entries

If an invalid record in `sys_be_shortcuts` is stored like this:

```
INSERT INTO sys_be_shortcuts (userid,route,arguments)
     VALUES (1,'record_edit','[]');
```

then the backend cannot be accessed anymore due to PHP
errors due to unguarded array key access of the
"arguments" contents.

This patch guards the array key access to prevent such
a situation, so an invalid shortcut can be deleted from
the menu.

Database records like this might happen for migrated older
installations.

Resolves: #104496
Releases: main, 12.4, 11.5
Change-Id: I350e620eb403e53d1828cf5dedaab633ba00db55
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/85464


Tested-by: default avatarStefan Bürk <stefan@buerk.tech>
Tested-by: default avatarcore-ci <typo3@b13.com>
Reviewed-by: default avatarStefan Bürk <stefan@buerk.tech>
parent 5ad8a56d
Branches
Tags
No related merge requests found
......@@ -475,7 +475,7 @@ class ShortcutRepository
$routeIdentifier = $row['route'] ?? '';
$arguments = json_decode($row['arguments'] ?? '', true) ?? [];
if ($routeIdentifier === 'record_edit' && is_array($arguments['edit'])) {
if ($routeIdentifier === 'record_edit' && is_array($arguments['edit'] ?? null)) {
$shortcut['table'] = (string)(key($arguments['edit']) ?? '');
$shortcut['recordid'] = key($arguments['edit'][$shortcut['table']]);
......@@ -636,8 +636,8 @@ class ShortcutRepository
{
switch ($routeIdentifier) {
case 'record_edit':
$table = $shortcut['table'];
$recordid = $shortcut['recordid'];
$table = $shortcut['table'] ?? '';
$recordid = $shortcut['recordid'] ?? 0;
$icon = '';
if ($shortcut['type'] === 'edit') {
......
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