Issue Bug Closed

#104834Possible PHP warning with checkboxToggle

Xavier Perseguers 09/05/24, 13:32 updated 10/15/24, 09:06

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.

Reviews 2

History 37

  1. Gerrit Code Review pushed patch set 1 for main to change 85900 status New Under Review 09/05/24, 13:33

  2. Gerrit Code Review pushed patch set 1 for 12.4 to change 85878 09/05/24, 16:25

  3. Anonymous commented and changed status Under Review Resolved done 0 % 100 % 09/05/24, 16:30

    Applied in changeset commit:f8accf52c184009fef6e4d52bef8a991fc35fcb2.

  4. Gerrit Code Review pushed patch set 2 for 12.4 to change 85878 status Resolved Under Review 09/05/24, 16:48

  5. Gerrit Code Review pushed patch set 3 for 12.4 to change 85878 09/05/24, 16:49

  6. Anonymous commented and changed status Under Review Resolved 09/05/24, 17:05

    Applied in changeset commit:fd712a3bdd112cee7062eb9295064df5e735fd72.

  7. Benni Mack changed status Resolved Closed 10/15/24, 09:06