[TASK] Replace static variable with class variable in FileInfo 67/56867/7
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 10:04:31 +0000 (12:04 +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/56867
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-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 74ae2c0..0dbcc16 100644 (file)
@@ -68,7 +68,9 @@ class ImageInfo extends FileInfo implements LoggerAwareInterface
             }
             // 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.
@@ -114,19 +116,4 @@ class ImageInfo extends FileInfo implements LoggerAwareInterface
 
         return $imagesSizes !== [] ? $imagesSizes : false;
     }
-
-    /**
-     * @return GraphicalFunctions
-     */
-    protected function getGraphicalFunctions()
-    {
-        static $graphicalFunctions = null;
-
-        if ($graphicalFunctions === null) {
-            $graphicalFunctions = GeneralUtility::makeInstance(GraphicalFunctions::class);
-            $graphicalFunctions->init();
-        }
-
-        return $graphicalFunctions;
-    }
 }