christophlehmann/imageoptimizer

PHP 8.1: Missing array key exists check in OptimizeImageService throws exception

akiessling opened this issue · 2 comments

We added webp to our list of image file extensions to generate webp versions directly in fluid templates.
The OptimizeImageService does not check if the config exists and thus throws an exception when it renders the template

PHP Warning: Undefined array key "webpOnProcessing" in /var/www/html/src/private/typo3conf/ext/imageoptimizer/Classes/OptimizeImageService.php line 70

if ((bool)$this->configuration[$extension . 'On' . $when] === false && $testMode === false) {

This should prevent the exception if no configuration is set

if (!isset($this->configuration[$extension . 'On' . $when]) || ((bool)$this->configuration[$extension . 'On' . $when] === false && $testMode === false)) {

Accepted. Would you create a PR?

yep, will do