Bug #85531
closedError with "select" and "group" field using l10n_display "defaultAsReadonly"
0%
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:
- 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
Updated by Mathias Brodala over 6 years ago
- Subject changed from Error with "db" field using l10n_display "defaultAsReadonly" to Error with "group" field using l10n_display "defaultAsReadonly"
- Description updated (diff)
Updated by Mathias Brodala over 6 years ago
- Description updated (diff)
- Is Regression set to Yes
Updated by Mathias Brodala over 6 years ago
- Subject changed from Error with "group" field using l10n_display "defaultAsReadonly" to Error with "select" and "group" field using l10n_display "defaultAsReadonly"
I noticed a similar issue today: if a select
field is configured with defaultAsReadonly
it will be displayed as readonly in translations just fine.
However the field value of the default language row is rendered as hidden field next to the visible readonly field. Since the field value in the default language row is unprocessed as described here it contains the number of related records. This in turn leads to a broken relation as soon as you save a translation since the original number of related records is now interpreted as foreign record UID.
How to reproduce:
1. Have a record and create a translation of this record
2. Have a field with 'l10n_display' => 'defaultAsReadonly'
in this record
3. Select a related record (with a UID > 1 to make it clearer) in the default language
4. Switch to the translation
5. Save the translation
After this, the translation will have the related record with UID 1 selected since the number of related records in the default language is 1. If you have a multi-select
you can see the same with multiple records: if you select 2 related records in the default language, the related record with UID 2 is selected in the translation, etc.
Updated by Mathias Brodala over 6 years ago
And another one: selectSingle
fields configured with defaultAsReadonly
don't display the value of the default language in translations. This is due to the itemFormElValue
being a plain number instead of an array which is the case without defaultAsReadonly
.
Updated by Mathias Brodala about 6 years ago
- Has duplicate Bug #84550: "l10n_display = defaultAsReadonly" throws exception for "type = group" elements added
Updated by Thomas Deinhamer about 5 years ago
Encountering this with TYPO3 v9 too.
Updated by Chris Müller about 4 years ago
Problem occurs also in TYPO3 10.4.6 (have it in a group field).
Updated by Oliver Bartsch almost 3 years ago
- Status changed from New to Closed
Hi, this has been fixed with #89152. Therefore, I'll close this issue now. In case you still encounter similar problems, please create a new issue with reference to this one.
Updated by Mathias Brodala almost 3 years ago
Oliver Bartsch wrote in #note-11:
Hi, this has been fixed with #89152. Therefore, I'll close this issue now. In case you still encounter similar problems, please create a new issue with reference to this one.
Sounds like the solution indeed, I need to get back to where I discovered this. In any case thanks for the fix!