Skip to content

Commit

Permalink
[BUGFIX] Prevent TypeError in CreateRecordReactionTable
Browse files Browse the repository at this point in the history
The `items` array in an itemsProcFunc does no
longer contain item arrays but SelectItem objects.
Therefore, the corresponding type hint is changed
in CreateRecordReactionTable and the code usages
are adjusted to prevent a TypeError.

Resolves: #100242
Related: #99739
Releases: main
Change-Id: I05be3bd33a816a6f957032d1482c37b3c33cbf9d
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/78205
Reviewed-by: Frank Nägler <frank.naegler@typo3.com>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Frank Nägler <frank.naegler@typo3.com>
  • Loading branch information
o-ba authored and bmack committed Mar 21, 2023
1 parent 78cb4e2 commit 062e850
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Expand Up @@ -32,7 +32,7 @@ class ReactionItemsProcFunc
public function validateAllowedTablesForExternalCreation(array &$fieldDefinition): void
{
foreach ($fieldDefinition['items'] as $key => $item) {
if (!CreateRecordReactionTable::fromProcFuncItem($item)->isAllowedForItemsProcFunc()) {
if (!CreateRecordReactionTable::fromSelectItem($item)->isAllowedForItemsProcFunc()) {
unset($fieldDefinition['items'][$key]);
}
}
Expand Down
Expand Up @@ -17,6 +17,8 @@

namespace TYPO3\CMS\Reactions\Validation;

use TYPO3\CMS\Core\Schema\Struct\SelectItem;

/**
* Validation class for tables to be allowed for record creation in the "create record" reaction
*
Expand All @@ -28,9 +30,9 @@ public function __construct(private readonly string $table)
{
}

public static function fromProcFuncItem(array $procFuncItem): CreateRecordReactionTable
public static function fromSelectItem(SelectItem $selectItem): CreateRecordReactionTable
{
return new self((string)($procFuncItem[1] ?? ''));
return new self((string)$selectItem->getValue());
}

public function isAllowedForCreation(): bool
Expand Down

0 comments on commit 062e850

Please sign in to comment.