[TASK] Replace static variable with class variable in FileInfo 99/56899/2
authorAnja Leichsenring <anja.leichsenring@typo3.com>
Sun, 6 May 2018 06:48:14 +0000 (08:48 +0200)
committerFrank Naegler <frank.naegler@typo3.org>
Wed, 9 May 2018 12:11:16 +0000 (14:11 +0200)
By removing the graphicFunctions object from global scope, unit
tests are easier to add in this area.

Change-Id: I8ddf4e0282d42325ecb03c98bede91bf6e1b636c
Resolves: #84933
Releases: master, 8.7
Reviewed-on: https://review.typo3.org/56899
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
typo3/sysext/core/Classes/Type/File/ImageInfo.php

index 77322f5..9c42960 100644 (file)
@@ -63,7 +63,9 @@ class ImageInfo extends FileInfo
             }
             // Fallback to IM/GM identify
             if ($this->imageSizes === false) {
-                $this->imageSizes = $this->getGraphicalFunctions()->imageMagickIdentify($this->getPathname());
+                $graphicalFunctions = GeneralUtility::makeInstance(GraphicalFunctions::class);
+                $graphicalFunctions->init();
+                $this->imageSizes = $graphicalFunctions->imageMagickIdentify($this->getPathname());
             }
 
             // In case the image size could not be retrieved, log the incident as a warning.
@@ -126,12 +128,8 @@ class ImageInfo extends FileInfo
      */
     protected function getGraphicalFunctions()
     {
-        static $graphicalFunctions = null;
-
-        if ($graphicalFunctions === null) {
-            $graphicalFunctions = GeneralUtility::makeInstance(GraphicalFunctions::class);
-            $graphicalFunctions->init();
-        }
+        $graphicalFunctions = GeneralUtility::makeInstance(GraphicalFunctions::class);
+        $graphicalFunctions->init();
 
         return $graphicalFunctions;
     }