Issue Bug Closed

#85531Error with "select" and "group" field using l10n_display "defaultAsReadonly"

Mathias Brodala 07/10/18, 16:00 updated 12/02/21, 10:10

Description

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

#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'];

A similar error occurs a little later on TYPO3v8:

#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;

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:

  1. Add 'l10n_display' => 'defaultAsReadonly' to $GLOBALS['TCA']['tt_content']['columns']['file_collections']
  2. Create an empty file collection on a page
  3. Add a File links content element to that page and select the created file collection
  4. Translate the page and the File links content element
  5. Edit the translated File links content element and see the error

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.