christophlehmann / imageoptimizer

TYPO3 Extension for lossless image optimization with binaries of your choice.
43 stars 22 forks source link

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

Closed akiessling closed 2 years ago

akiessling commented 2 years ago

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

https://github.com/christophlehmann/imageoptimizer/blob/1571a96963d14a7045a6500987af3ccaca86e921/Classes/OptimizeImageService.php#L70

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)) {
christophlehmann commented 2 years ago

Accepted. Would you create a PR?

akiessling commented 2 years ago

yep, will do