[BUGFIX] Improve exception output for ImageService 70/55370/6
authorGeorg Ringer <georg.ringer@gmail.com>
Tue, 16 Jan 2018 10:28:05 +0000 (11:28 +0100)
committerBenni Mack <benni@typo3.org>
Wed, 17 Jan 2018 10:05:54 +0000 (11:05 +0100)
Avoid spamming the log in PHP 7.2 due to get_class(null) if fetching the
image in ImageService->getImage() fails.

Resolves: #83570
Releases: master, 8.7, 7.6
Change-Id: Icc3c78f5b747842cee89d184134ff298b8e04a3a
Reviewed-on: https://review.typo3.org/55370
Reviewed-by: Stephan GroƟberndt <stephan@grossberndt.de>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Mattia D <mattia.dorigatti@brandnamic.com>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/extbase/Classes/Service/ImageService.php

index 9af53cf..6adeb6c 100644 (file)
@@ -127,7 +127,8 @@ class ImageService implements \TYPO3\CMS\Core\SingletonInterface
         }
 
         if (!($image instanceof File || $image instanceof FileReference)) {
-            throw new \UnexpectedValueException('Supplied file object type ' . get_class($image) . ' for ' . $src . ' must be File or FileReference.', 1382687163);
+            $class = is_object($image) ? get_class($image) : 'null';
+            throw new \UnexpectedValueException('Supplied file object type ' . $class . ' for ' . $src . ' must be File or FileReference.', 1382687163);
         }
 
         return $image;