Issue Bug Closed

#102241Undefined array index warning in TYPO3\CMS\Frontend\Imaging\GifBuilder

Hannes Bochmann 10/24/23, 10:02 updated 07/09/24, 15:19

Description

TypoScript setup:

file = GIFBUILDER
file {
    XY = 700,1000
    format = png
    10 = IMAGE
    10.file {
        import {
        data = levelmedia:-1, slide
        listNum = 0
        }
        width = 700c
        height = 560c
        treatIdAsReference = 1
    }
    21 = IMAGE
    21 {
        offset = 0,232
        file = ....png
        width = 700
        height = 1213
        if {
        value.data = page:bgcolor
        equals = 1
        }
    }
    22 < .21
    22 {
        file = ....png
        if.equals = 2
    }
    23 < .21
    23 {
        file = ....png
        if.equals = 3
    }
}

In the above setup only one image will be used. Either 21, 22 or 23 because of the if. statements. The GifBuilder takes care of the if. statements and removes all objects from the internal $this->setup configuration that do not match. Later in line 245 the configuration for all keys (21, 22 and 23) is retrieved but some keys might already be unset in line 231 due to the if. statements. I’m not sure if it’s better to remove keys from $sKeyArray as well when when a if. statement is not met and the setup is cleaned. Or simply add a null coalescing operator in line 245.

Error message: PHP Warning: Undefined array key 22 in /var/www/html/vendor/typo3/cms-frontend/Classes/Imaging/GifBuilder.php line 245
TYPO3 version: 12.4.7

Reviews 2

History 49

  1. Tobias Gülzow commented 01/17/24, 14:20

    Hi everyone.

    We are having exactly the same problem.

    Our current workaround:
    Use the gifbuilder-ConfPreProcess hook to parse through the config and remove ts settings with a problematic if clause.

    Tobi

  2. Gerrit Code Review pushed patch set 1 for main to change 83559 status New Under Review 03/21/24, 13:03

  3. Gerrit Code Review pushed patch set 2 for main to change 83559 03/21/24, 13:17

  4. Simon Schaufelberger commented 03/22/24, 09:53

    Does this bug also occur on TYPO3 11 or only since 12?

  5. Gerrit Code Review pushed patch set 1 for 12.4 to change 83570 03/22/24, 11:17

  6. Gerrit Code Review pushed patch set 2 for 12.4 to change 83570 03/22/24, 11:18

  7. Gerrit Code Review pushed patch set 3 for 12.4 to change 83570 03/22/24, 11:19

  8. Oliver Bartsch commented and changed status Under Review Resolved done 0 % 100 % 03/22/24, 12:35

    Applied in changeset commit:3d18a57a9fd68d7a461bb012386a8feb4338c20d.

  9. Benni Mack changed status Resolved Closed 07/09/24, 15:19