Backend selectTree PHP Warning
Due to undefined [config][items] of renderType=selectTree a PHP Warning is issued:
#1476107295: PHP Warning: array_column() expects parameter 1 to be array, null given in typo3_src_8.7/typo3/sysext/backend/Classes/Form/FormDataProvider/TcaRecordTitle.php line 241
The reason is that no FormDataProvider is generating the
items array for a tree (only for all other types of select elements).
A cheap workaround is to add an empty
items array to the TCA:
'category' => [ 'exclude' => false, 'label' => 'Foo', 'config' => [ 'type' => 'select', 'renderType' => 'selectTree', 'foreign_table' => 'sys_category', 'foreign_table_where' => 'AND sys_category.pid IN (###PAGE_TSCONFIG_IDLIST###) AND sys_category.sys_language_uid IN (-1, 0) ORDER BY sys_category.sorting ASC', 'items' => , 'minitems' => 1, 'maxitems' => 1, 'treeConfig' => [ 'parentField' => 'parent', 'appearance' => [ 'expandAll' => true, 'showHeader' => true, 'maxLevels' => 2, 'nonSelectableLevels' => '0,1' ], ] ], ],
The core needs a fix to handle the missing items array correctly.
We face this issue with a custom extension that uses this TCA inside a record that is nested with IRRE in the main record.
Main record: project
Nested record: assignment (relation to project and to sys_category)
#1 Updated by Gerrit Code Review 25 days ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61122
#4 Updated by Joerg Kummer 24 days ago
@Markus Klein - Thx for extended description to reproduce.
As mentioned in our Gerrit, I can't reproduce such PHP warning in my local review installations with development settings in TYPO3 v8.7 and v10.0-dev with PHP 7.2.
I understand and accept the requirement for this issue, but also want to verify your patch. Maybe I have a misconfiguration to reproduce.
I tried different TCA configurations, and also your example TCA configuration by overwrite my preferred extension for such cases in: EXT:styleguide/Configuration/TCA/tx_styleguide_elements_select.php column select_single_1 (with and without the array part for 'items' => ) with no success. I also emptied all sys_category entries in DB. Backend worked in all cases as expected, without warnings and no error entries in my Apache error log.
Do you have another idea to reproduce, so we can improve the core at this part?
Just to avoid that someone more `waste at least half a day searching for the "error" after an upgrade to v8`... as you mentioned in Slack.