Skip to content

Commit

Permalink
[BUGFIX] Prevent array access warning on deleted database record
Browse files Browse the repository at this point in the history
If a sys_file record is directly deleted from database, some undefined
array index warnings are triggered if the file is assigned to another
database record.

Releases: main, 11.5
Resolves: #97987
Change-Id: I2ce115024e637cffacc512528e79b1bb4059f173
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/75254
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
  • Loading branch information
Daniel authored and lolli42 committed Aug 12, 2022
1 parent 13dc5aa commit 6d7e660
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Expand Up @@ -362,7 +362,7 @@ protected function renderForeignRecordHeader(array $data, string $ariaAttributes
// Renders a thumbnail for the header
if (($GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'] ?? false) && !empty($inlineConfig['appearance']['headerThumbnail']['field'])) {
$fieldValue = $rec[$inlineConfig['appearance']['headerThumbnail']['field']];
$fileUid = $fieldValue[0]['uid'];
$fileUid = $fieldValue[0]['uid'] ?? null;

if (!empty($fileUid)) {
try {
Expand Down
Expand Up @@ -106,7 +106,7 @@ public function addData(array $result)
// Fetch field of this foreign row from db
if (MathUtility::canBeInterpretedAsInteger($foreignUid)) {
$foreignRow = $this->getDatabaseRow($foreignTable, (int)$foreignUid, $foreignTableTypeField);
if ($foreignRow[$foreignTableTypeField]) {
if (!empty($foreignRow[$foreignTableTypeField])) {
// @todo: It might be necessary to fetch the value from default language record as well here,
// @todo: this was buggy in the "old" implementation and never worked. It was therefor left out here for now.
// @todo: To implement that, see if the foreign row is a localized overlay, fetch default and merge exclude
Expand Down
Expand Up @@ -45,7 +45,13 @@ public function getInlineLabel(array &$params)
}

// In case of a group field uid_local is a resolved array
$fileRecord = $params['row']['uid_local'][0]['row'];
$fileRecord = $params['row']['uid_local'][0]['row'] ?? null;

if ($fileRecord === null) {
// no file record so nothing more to do
$params['title'] = $params['row']['uid'];
return;
}

// Configuration
$title = '';
Expand Down

0 comments on commit 6d7e660

Please sign in to comment.