[BUGFIX] Ensure type safety for ViewHelper calling ImageService 17/59617/2
authorAnja Leichsenring <aleichsenring@ab-softlab.de>
Fri, 1 Feb 2019 17:49:45 +0000 (18:49 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Fri, 1 Feb 2019 18:07:56 +0000 (19:07 +0100)
The ImageService::getImage requires a string as first and a boolean as
third parameter. The ThumbnailViewHelper must respect this requirement.

Resolves: #87621
Relates: #87599
Releases: master
Change-Id: Ib84f88665fd692629efdb54a33ff83263abe6bfe
Reviewed-on: https://review.typo3.org/59617
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Mona Muzaffar <mona.muzaffar@gmx.de>
Tested-by: Mona Muzaffar <mona.muzaffar@gmx.de>
Tested-by: TYPO3com <noreply@typo3.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/backend/Classes/ViewHelpers/ThumbnailViewHelper.php

index 0ac0a38..32ec514 100644 (file)
@@ -46,12 +46,12 @@ class ThumbnailViewHelper extends ImageViewHelper
      */
     public function render()
     {
-        if (($this->arguments['src'] === null && $this->arguments['image'] === null) || ($this->arguments['src'] !== null && $this->arguments['image'] !== null)) {
+        if (($this->arguments['src'] === '' && $this->arguments['image'] === null) || ($this->arguments['src'] !== '' && $this->arguments['image'] !== null)) {
             throw new Exception('You must either specify a string src or a File object.', 1533290762);
         }
 
         try {
-            $image = $this->imageService->getImage($this->arguments['src'], $this->arguments['image'], $this->arguments['treatIdAsReference']);
+            $image = $this->imageService->getImage((string)$this->arguments['src'], $this->arguments['image'], (bool)$this->arguments['treatIdAsReference']);
 
             $cropString = $this->arguments['crop'];
             if ($cropString === null && $image->hasProperty('crop') && $image->getProperty('crop')) {