Bug #88624

Backend selectTree PHP Warning

Added by Markus Klein 4 months ago. Updated 2 months ago.

Status:
Resolved
Priority:
Should have
Assignee:
Category:
Backend API
Target version:
-
Start date:
2019-06-24
Due date:
% Done:

100%

TYPO3 Version:
8
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

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)

Associated revisions

Revision d7f1c9ea (diff)
Added by Markus Klein 2 months ago

[BUGFIX] Prevent PHP Warning with TCA selectTree

Make sure there is actually an 'items' array in the processedTCA
before validating the items.

Resolves: #88624
Releases: master, 9.5, 8.7
Change-Id: I1fb6d47ac017ce6950926387387ad19d8445af74
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61122
Tested-by: TYPO3com <>
Tested-by: Tymoteusz Motylewski <>
Tested-by: Anja Leichsenring <>
Reviewed-by: Oliver Klee <>
Reviewed-by: Tymoteusz Motylewski <>
Reviewed-by: Anja Leichsenring <>

Revision a2448a2b (diff)
Added by Markus Klein 2 months ago

[BUGFIX] Prevent PHP Warning with TCA selectTree

Make sure there is actually an 'items' array in the processedTCA
before validating the items.

Resolves: #88624
Releases: master, 9.5, 8.7
Change-Id: I1fb6d47ac017ce6950926387387ad19d8445af74
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61358
Tested-by: TYPO3com <>
Tested-by: Anja Leichsenring <>
Reviewed-by: Anja Leichsenring <>

Revision 5d88e68d (diff)
Added by Markus Klein 2 months ago

[BUGFIX] Prevent PHP Warning with TCA selectTree

Make sure there is actually an 'items' array in the processedTCA
before validating the items.

Resolves: #88624
Releases: master, 9.5, 8.7
Change-Id: I1fb6d47ac017ce6950926387387ad19d8445af74
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61359
Tested-by: TYPO3com <>
Tested-by: Anja Leichsenring <>
Reviewed-by: Anja Leichsenring <>

History

#1 Updated by Gerrit Code Review 4 months 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

#2 Updated by Markus Klein 4 months ago

  • PHP Version set to 7.2

#3 Updated by Markus Klein 4 months ago

  • Description updated (diff)

#4 Updated by Joerg Kummer 4 months 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.

#5 Updated by Gerrit Code Review 3 months ago

Patch set 2 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

#6 Updated by Gerrit Code Review 3 months ago

Patch set 3 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

#7 Updated by Gerrit Code Review 2 months ago

Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61358

#8 Updated by Gerrit Code Review 2 months ago

Patch set 1 for branch TYPO3_8-7 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61359

#9 Updated by Markus Klein 2 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF