Project

General

Profile

Actions

Bug #104834

closed

Possible PHP warning with checkboxToggle

Added by Xavier Perseguers about 2 months ago. Updated 13 days ago.

Status:
Closed
Priority:
Should have
Category:
FormEngine aka TCEforms
Start date:
2024-09-05
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
12
PHP Version:
Tags:
Complexity:
no-brainer
Is Regression:
Sprint Focus:

Description

Under some circumstance, it's possible that 'items' has been omitted in the TCA definition and this causes a PHP warning with that block:

        // Traversing the array of items
        $items = $this->data['parameterArray']['fieldConf']['config']['items'];

        $numberOfItems = count($items);
        if ($numberOfItems === 0) {
            $items[] = ['label' => ''];
            $numberOfItems = 1;
        }

Since there is already a proper check and fallback for emptiness, the null coalescing operator should be used as well in the first place:

$items = $this->data['parameterArray']['fieldConf']['config']['items'] ?? [];

Problem has been spotted in TYPO3 v11 already but code hasn't changed in v12.

Actions

Also available in: Atom PDF