Skip to content

Commit

Permalink
[TASK] Replace static variable with class variable in FileInfo
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Anja Leichsenring authored and NeoBlack committed May 9, 2018
1 parent 6dd767b commit 6907f9a
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions typo3/sysext/core/Classes/Type/File/ImageInfo.php
Expand Up @@ -68,7 +68,9 @@ protected function getImageSizes()
}
// 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.
Expand Down Expand Up @@ -114,19 +116,4 @@ protected function extractSvgImageSizes()

return $imagesSizes !== [] ? $imagesSizes : false;
}

/**
* @return GraphicalFunctions
*/
protected function getGraphicalFunctions()
{
static $graphicalFunctions = null;

if ($graphicalFunctions === null) {
$graphicalFunctions = GeneralUtility::makeInstance(GraphicalFunctions::class);
$graphicalFunctions->init();
}

return $graphicalFunctions;
}
}

0 comments on commit 6907f9a

Please sign in to comment.