Skip to content

Commit a59a013

Browse files
committed
[BUGFIX] Avoid array access warning in cleanup:missingrelations CLI
Use null coalescing operator to sanitize some array accesses. In TYPO3 v12, this code is within class ReferenceIndex. Resolves: #104812 Releases: main, 13.4, 12.4 Change-Id: Iced99a855d6eccfc01747827a2b6913ff92e1b61 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/87150 Reviewed-by: Andreas Kienast <akienast@scripting-base.de> Tested-by: Simon Praetorius <simon@praetorius.me> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: core-ci <typo3@b13.com> Reviewed-by: Andreas Nedbal <andy@pixelde.su> Reviewed-by: Simon Praetorius <simon@praetorius.me> Tested-by: Andreas Nedbal <andy@pixelde.su>
1 parent f73bae6 commit a59a013

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

typo3/sysext/lowlevel/Classes/Command/MissingRelationsCommand.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,10 +505,13 @@ protected function setReferenceValue(string $hash): string|bool
505505
*/
506506
protected function setReferenceValue_dbRels(array $refRec, array $itemArray, array &$dataArray, string $flexPointer = ''): string|bool
507507
{
508-
if ((int)$itemArray[$refRec['sorting']]['id'] === (int)$refRec['ref_uid'] && (string)$itemArray[$refRec['sorting']]['table'] === (string)$refRec['ref_table']) {
508+
$sorting = $refRec['sorting'] ?? null;
509+
if ((int)($itemArray[$sorting]['id'] ?? 0) === (int)$refRec['ref_uid']
510+
&& (string)($itemArray[$sorting]['table'] ?? '') === (string)$refRec['ref_table']
511+
) {
509512
// Setting or removing value:
510513
// Remove value:
511-
unset($itemArray[$refRec['sorting']]);
514+
unset($itemArray[$sorting]);
512515
// Traverse and compile new list of records:
513516
$saveValue = [];
514517
foreach ($itemArray as $pair) {
@@ -525,7 +528,9 @@ protected function setReferenceValue_dbRels(array $refRec, array $itemArray, arr
525528
$dataArray[$refRec['tablename']][$refRec['recuid']][$refRec['field']] = implode(',', $saveValue);
526529
}
527530
} else {
528-
return 'ERROR: table:id pair "' . $refRec['ref_table'] . ':' . $refRec['ref_uid'] . '" did not match that of the record ("' . $itemArray[$refRec['sorting']]['table'] . ':' . $itemArray[$refRec['sorting']]['id'] . '") in sorting index "' . $refRec['sorting'] . '"';
531+
return 'ERROR: table:id pair "' . $refRec['ref_table'] . ':' . $refRec['ref_uid']
532+
. '" did not match that of the record ("' . ($itemArray[$sorting]['table'] ?? '') . ':' . ($itemArray[$sorting]['id'] ?? '') . '")'
533+
. ' in sorting index "' . $sorting . '"';
529534
}
530535
return false;
531536
}

0 commit comments

Comments
 (0)