Bug #85531

Updated by Mathias Brodala over 1 year ago

When editing a translated record which contains a @group@ field whose @l10n_display@ is configured as @defaultAsReadonly@ an exception occurs: occurs in TYPO3v8:

<pre>
#1476107295: PHP Warning: Invalid argument supplied for foreach() in /.../typo3/sysext/backend/Classes/Form/Element/GroupElement.php line 158 (More information)

TYPO3\CMS\Core\Error\Exception thrown in file
/.../typo3/sysext/core/Classes/Error/ErrorHandler.php in line 107.

17 TYPO3\CMS\Core\Error\ErrorHandler::handleError(2, "Invalid argument supplied for foreach()", "/.../typo3/sysext/backend/Classes/Form/Element/GroupElement.php", 158, array)

/.../typo3/sysext/backend/Classes/Form/Element/GroupElement.php:
00156: }
00157: } elseif ($internalType === 'db') {
00158: foreach ($selectedItems as $selectedItem) {
00159: $tableWithUid = $selectedItem['table'] . '_' . $selectedItem['uid'];
00160: $listOfSelectedValues[] = $tableWithUid;
</pre>

This fails even earlier on the latest master (thus upcoming v9):

<pre>
#1476107295: PHP Warning:
count(): Parameter must be an array or an object that implements Countable in /.../typo3/sysext/backend/Classes/Form/Element/GroupElement.php line 120 (More information)

TYPO3\CMS\Core\Error\Exception thrown in file
/.../typo3/sysext/core/Classes/Error/ErrorHandler.php in line 115.

38 TYPO3\CMS\Core\Error\ErrorHandler::handleError(2, "count(): Parameter must be an array or an object that implements Countable", "/.../typo3/sysext/backend/Classes/Form/Element/GroupElement.php", 120, array)
37 count("1")

/.../typo3/sysext/backend/Classes/Form/Element/GroupElement.php:
00118:
00119: $selectedItems = $parameterArray['itemFormElValue'];
00120: $selectedItemsCount = count($selectedItems);
00121:
00122: $maxItems = $config['maxitems'];
</pre>

A similar error occurs a little later on TYPO3v8:

<pre>
#1476107295: PHP Warning: Invalid argument supplied for foreach() in /.../typo3/sysext/backend/Classes/Form/Element/GroupElement.php line 158 (More information)

TYPO3\CMS\Core\Error\Exception thrown in file
/.../typo3/sysext/core/Classes/Error/ErrorHandler.php in line 107.

17 TYPO3\CMS\Core\Error\ErrorHandler::handleError(2, "Invalid argument supplied for foreach()", "/.../typo3/sysext/backend/Classes/Form/Element/GroupElement.php", 158, array)

/.../typo3/sysext/backend/Classes/Form/Element/GroupElement.php:
00156: }
00157: } elseif ($internalType === 'db') {
00158: foreach ($selectedItems as $selectedItem) {
00159: $tableWithUid = $selectedItem['table'] . '_' . $selectedItem['uid'];
00160: $listOfSelectedValues[] = $tableWithUid;
</pre>

The code here expects an array but gets an integer (number of related records) instead.

This is triggered by the @SingleFieldContainer@ which replaces the @databaseRow@ value prepared by @TcaGroup@ with the raw value from @defaultLanguageRow@ in case @l10n_display@ is set to @defaultAsReadonly@.

This error does not occur on TYPO3v7 but the field is empty instead there.


This can be reproduced e.g. with the following steps:

# Add @'l10n_display' => 'defaultAsReadonly'@ to @$GLOBALS['TCA']['tt_content']['columns']['file_collections']@
# Create an empty file collection on a page
# Add a _File links_ content element to that page and select the created file collection
# Translate the page and the _File links_ content element
# Edit the translated _File links_ content element and see the error

Back