From 5acedb083e4a7e8be87577ef955358d2b662ce1a Mon Sep 17 00:00:00 2001 From: Benni Mack <benni@typo3.org> Date: Wed, 20 Sep 2023 15:00:06 +0200 Subject: [PATCH] [!!!][TASK] Remove cache_imagesizes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change removes the cache "imagesizes" along with the public methods within GraphicalFunctions. The main reason for having cache_imagesizes back in TYPO3 v4.x was that detecting the image sizes was done via ImageMagick solely. Nowadays, the ImageInfo functionality is used, which uses - getimagesize() - exif_read_data() before falling back to ImageMagick identify. Most places in TYPO3 Core already use ImageInfo directly without using the cache. A image size calculation is nowadays with SSD much faster than a decade before, whereas a DB cache (by default) for cache_imagesizes has a much more latency. As cache_imagesizes is solely used for local files, remote FAL drivers do not have a problem here as well. Removed public methods: - GraphicalFunctions->cacheImageDimensions() - GraphicalFunctions->getCachedImageDimensions() The main public method GraphicalFunctions->getImageDimensions() still continues to exist and work as before. Resolves: #102009 Releases: main Change-Id: I6075e796b5e729733bd60eb7d2e005f5f5cc4b33 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/81105 Tested-by: Benni Mack <benni@typo3.org> Reviewed-by: Stefan Bürk <stefan@buerk.tech> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Stefan Bürk <stefan@buerk.tech> Reviewed-by: Benni Mack <benni@typo3.org> Tested-by: core-ci <typo3@b13.com> --- .../core/Classes/DataHandling/DataHandler.php | 3 - .../Classes/Imaging/GraphicalFunctions.php | 121 +++--------------- .../Processing/LocalImageProcessor.php | 23 ++-- .../Configuration/DefaultConfiguration.php | 8 -- typo3/sysext/core/Configuration/Services.yaml | 5 - ...Breaking-102009-ImagesizesCacheRemoved.rst | 63 +++++++++ .../ContentObject/ContentObjectRenderer.php | 14 +- .../ContentObjectRendererTest.php | 7 - .../Configuration/Cache/CustomCachePreset.php | 1 - .../Cache/DatabaseCachePreset.php | 2 - .../Configuration/Cache/FileCachePreset.php | 3 - .../Controller/EnvironmentController.php | 28 ++-- .../Php/MethodCallMatcher.php | 14 ++ 13 files changed, 125 insertions(+), 167 deletions(-) create mode 100644 typo3/sysext/core/Documentation/Changelog/13.0/Breaking-102009-ImagesizesCacheRemoved.rst diff --git a/typo3/sysext/core/Classes/DataHandling/DataHandler.php b/typo3/sysext/core/Classes/DataHandling/DataHandler.php index 8c35561158e3..53a2066e5551 100644 --- a/typo3/sysext/core/Classes/DataHandling/DataHandler.php +++ b/typo3/sysext/core/Classes/DataHandling/DataHandler.php @@ -9215,9 +9215,6 @@ class DataHandler implements LoggerAwareInterface * * The following cache_* are intentionally not cleared by 'all' * - * - imagesizes: Clearing this table would cause a lot of unneeded - * Imagemagick calls because the size information has - * to be fetched again after clearing. * - all caches inside the cache manager that are inside the group "system" * - they are only needed to build up the core system and templates. * If the group of system caches needs to be deleted explicitly, use diff --git a/typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php b/typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php index 1f32964d5a94..e418820dafdc 100644 --- a/typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php +++ b/typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php @@ -15,7 +15,6 @@ namespace TYPO3\CMS\Core\Imaging; -use TYPO3\CMS\Core\Cache\CacheManager; use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Type\File\ImageInfo; use TYPO3\CMS\Core\Utility\CommandUtility; @@ -28,7 +27,7 @@ use TYPO3\CMS\Core\Utility\StringUtility; * Standard graphical functions * * Class contains a bunch of cool functions for manipulating graphics with GDlib/Freetype and ImageMagick. - * VERY OFTEN used with gifbuilder that extends this class and provides a TypoScript API to using these functions + * VERY OFTEN used with gifbuilder that uses this class and provides a TypoScript API to using these functions */ class GraphicalFunctions { @@ -464,114 +463,24 @@ class GraphicalFunctions */ public function getImageDimensions($imageFile) { - $returnArr = null; preg_match('/([^\\.]*)$/', $imageFile, $reg); - if (file_exists($imageFile) && in_array(strtolower($reg[0]), $this->imageFileExt, true)) { - $returnArr = $this->getCachedImageDimensions($imageFile); - if (!$returnArr) { - $imageInfoObject = GeneralUtility::makeInstance(ImageInfo::class, $imageFile); - if ($imageInfoObject->getWidth()) { - $returnArr = [ - $imageInfoObject->getWidth(), - $imageInfoObject->getHeight(), - strtolower($reg[0]), - $imageFile, - ]; - $this->cacheImageDimensions($returnArr); - } else { - // Size could not be determined, return null instead of boolean - $returnArr = null; - } - } + if (!file_exists($imageFile)) { + return null; } - return $returnArr; - } - - /** - * Caches the result of the getImageDimensions function into the database. Does not check if the file exists. - * - * @param array $identifyResult Result of the getImageDimensions function - * - * @return bool always TRUE - */ - public function cacheImageDimensions(array $identifyResult) - { - $filePath = $identifyResult[3]; - $statusHash = $this->generateStatusHashForImageFile($filePath); - $identifier = $this->generateCacheKeyForImageFile($filePath); - - $cache = GeneralUtility::makeInstance(CacheManager::class)->getCache('imagesizes'); - $imageDimensions = [ - 'hash' => $statusHash, - 'imagewidth' => $identifyResult[0], - 'imageheight' => $identifyResult[1], - ]; - $cache->set($identifier, $imageDimensions); - - return true; - } - - /** - * Fetches the cached image dimensions from the cache. Does not check if the image file exists. - * - * @param string $filePath The absolute image file path - * - * @return array|bool an array where [0]/[1] is w/h, [2] is extension and [3] is the file name, - * or FALSE for a cache miss - */ - public function getCachedImageDimensions($filePath) - { - $statusHash = $this->generateStatusHashForImageFile($filePath); - $identifier = $this->generateCacheKeyForImageFile($filePath); - $cache = GeneralUtility::makeInstance(CacheManager::class)->getCache('imagesizes'); - $cachedImageDimensions = $cache->get($identifier); - if (!isset($cachedImageDimensions['hash'])) { - return false; - } - - if ($cachedImageDimensions['hash'] !== $statusHash) { - // The file has changed. Delete the cache entry. - $cache->remove($identifier); - $result = false; - } else { - preg_match('/([^\\.]*)$/', $filePath, $imageExtension); - $result = [ - (int)$cachedImageDimensions['imagewidth'], - (int)$cachedImageDimensions['imageheight'], - strtolower($imageExtension[0]), - $filePath, + // @todo: check if we actually need this, ass ImageInfo deals with this much more professionally + if (!in_array(strtolower($reg[0]), $this->imageFileExt, true)) { + return null; + } + $imageInfoObject = GeneralUtility::makeInstance(ImageInfo::class, $imageFile); + if ($imageInfoObject->isFile() && $imageInfoObject->getWidth()) { + return [ + $imageInfoObject->getWidth(), + $imageInfoObject->getHeight(), + $imageInfoObject->getExtension(), + $imageFile, ]; } - - return $result; - } - - /** - * Creates the key for the image dimensions cache for an image file. - * - * This method does not check if the image file actually exists. - * - * @param string $filePath Absolute image file path - * - * @return string the hash key (an SHA1 hash), will not be empty - */ - protected function generateCacheKeyForImageFile($filePath) - { - return sha1(PathUtility::stripPathSitePrefix($filePath)); - } - - /** - * Creates the status hash to check whether a file has been changed. - * - * @param string $filePath Absolute image file path - * - * @return string the status hash (an SHA1 hash) - */ - protected function generateStatusHashForImageFile($filePath) - { - $fileStatus = stat($filePath); - - return sha1($fileStatus['mtime'] . $fileStatus['size']); + return null; } /** diff --git a/typo3/sysext/core/Classes/Resource/Processing/LocalImageProcessor.php b/typo3/sysext/core/Classes/Resource/Processing/LocalImageProcessor.php index 728d3df950f8..614133b8078b 100644 --- a/typo3/sysext/core/Classes/Resource/Processing/LocalImageProcessor.php +++ b/typo3/sysext/core/Classes/Resource/Processing/LocalImageProcessor.php @@ -17,7 +17,7 @@ namespace TYPO3\CMS\Core\Resource\Processing; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerAwareTrait; -use TYPO3\CMS\Core\Imaging\GraphicalFunctions; +use TYPO3\CMS\Core\Type\File\ImageInfo; use TYPO3\CMS\Core\Utility\GeneralUtility; /** @@ -68,12 +68,12 @@ class LocalImageProcessor implements ProcessorInterface, LoggerAwareInterface $task->getTargetFile()->setUsesOriginalFile(); } elseif (!empty($result['filePath']) && file_exists($result['filePath'])) { $task->setExecuted(true); - $imageDimensions = $this->getGraphicalFunctionsObject()->getImageDimensions($result['filePath']); + $imageInformation = GeneralUtility::makeInstance(ImageInfo::class, $result['filePath']); $task->getTargetFile()->setName($task->getTargetFileName()); $task->getTargetFile()->updateProperties([ - 'width' => $imageDimensions[0] ?? 0, - 'height' => $imageDimensions[1] ?? 0, - 'size' => filesize($result['filePath']), + 'width' => $imageInformation->getWidth(), + 'height' => $imageInformation->getHeight(), + 'size' => $imageInformation->getSize(), 'checksum' => $task->getConfigurationChecksum(), ]); $task->getTargetFile()->updateWithLocalFile($result['filePath']); @@ -112,11 +112,11 @@ class LocalImageProcessor implements ProcessorInterface, LoggerAwareInterface // have no API for fetching file metadata from a remote file. $localProcessedFile = $storage->getFileForLocalProcessing($task->getTargetFile(), false); $task->setExecuted(true); - $imageDimensions = $this->getGraphicalFunctionsObject()->getImageDimensions($localProcessedFile); + $imageInformation = GeneralUtility::makeInstance(ImageInfo::class, $localProcessedFile); $properties = [ - 'width' => $imageDimensions[0] ?? 0, - 'height' => $imageDimensions[1] ?? 0, - 'size' => filesize($localProcessedFile), + 'width' => $imageInformation->getWidth(), + 'height' => $imageInformation->getHeight(), + 'size' => $imageInformation->getSize(), 'checksum' => $task->getConfigurationChecksum(), ]; $task->getTargetFile()->updateProperties($properties); @@ -146,9 +146,4 @@ class LocalImageProcessor implements ProcessorInterface, LoggerAwareInterface return $helper; } - - protected function getGraphicalFunctionsObject(): GraphicalFunctions - { - return GeneralUtility::makeInstance(GraphicalFunctions::class); - } } diff --git a/typo3/sysext/core/Configuration/DefaultConfiguration.php b/typo3/sysext/core/Configuration/DefaultConfiguration.php index 5d84d29fa3a4..dde0a42b743a 100644 --- a/typo3/sysext/core/Configuration/DefaultConfiguration.php +++ b/typo3/sysext/core/Configuration/DefaultConfiguration.php @@ -191,14 +191,6 @@ return [ ], 'groups' => ['pages'], ], - 'imagesizes' => [ - 'frontend' => \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class, - 'backend' => \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class, - 'options' => [ - 'defaultLifetime' => 0, - ], - 'groups' => ['lowlevel'], - ], 'assets' => [ 'frontend' => \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class, 'backend' => \TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend::class, diff --git a/typo3/sysext/core/Configuration/Services.yaml b/typo3/sysext/core/Configuration/Services.yaml index 064596be9916..8f3b4606260c 100644 --- a/typo3/sysext/core/Configuration/Services.yaml +++ b/typo3/sysext/core/Configuration/Services.yaml @@ -299,11 +299,6 @@ services: factory: ['@TYPO3\CMS\Core\Cache\CacheManager', 'getCache'] arguments: ['rootline'] - cache.imagesizes: - class: TYPO3\CMS\Core\Cache\Frontend\FrontendInterface - factory: ['@TYPO3\CMS\Core\Cache\CacheManager', 'getCache'] - arguments: ['imagesizes'] - cache.l10n: class: TYPO3\CMS\Core\Cache\Frontend\FrontendInterface factory: ['@TYPO3\CMS\Core\Cache\CacheManager', 'getCache'] diff --git a/typo3/sysext/core/Documentation/Changelog/13.0/Breaking-102009-ImagesizesCacheRemoved.rst b/typo3/sysext/core/Documentation/Changelog/13.0/Breaking-102009-ImagesizesCacheRemoved.rst new file mode 100644 index 000000000000..e121d0efeca9 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/13.0/Breaking-102009-ImagesizesCacheRemoved.rst @@ -0,0 +1,63 @@ +.. include:: /Includes.rst.txt + +.. _breaking-102009-1695376655: + +============================================ +Breaking: #102009 - imagesizes cache removed +============================================ + +See :issue:`102009` + +Description +=========== + +A cache layer called "imagesizes" was added in 2004 (= TYPO3 3.x) to cache +width and height of any kind of images - mostly generated by GIFBuilder or +ImageMagick. This was using the PHP function :php:`getimagesizes` or, if this +failed, ImageMagick identify command, which is costly. + +In 2012, the new processing layer for File Abstraction Layer (FAL - via +"sys_file_processedfile") was introduced with a more modern API, which persists +final information about processed images in a separate database table. + +Any kind of information processing then is first checked in FAL and then stored +again in `cache_imagesizes`. Some more files, which do not use FAL still utilize +this functionality, but the second level cache layer (by default in the database), +is unneeded nowadays. + +For this reason, the lowlevel cache "imagesizes" is removed along with some +methods which were not marked as internal, but marked public: + +- :php:`TYPO3\CMS\Core\Imaging\GraphicalFunctions->cacheImageDimensions()` +- :php:`TYPO3\CMS\Core\Imaging\GraphicalFunctions->getCachedImageDimensions()` + +The main entrypoint :php:`TYPO3\CMS\Core\Imaging\GraphicalFunctions->getImageDimensions()` +is still available but does not use a cache layer anymore. + + +Impact +====== + +Calling the removed public methods will result in a fatal PHP error. In addition, +accessing the database table directly or via TYPO3's CacheManager is not possible +anymore, as the "imagesizes" cache is removed. + + +Affected installations +====================== + +TYPO3 installations which use the cache directly or access these methods +directly, which is very very unlikely. + + +Migration +========= + +The now unused database tables are automatically removed when using the database +compare update is called. When trying to retrieve image dimensions, +the :php:`TYPO3\CMS\Core\Type\File\Imageinfo` PHP class should be used instead in +favor of the main GraphicalFunctions method. + +The removed methods should be moved also towards the :php:`Imageinfo` PHP class. + +.. index:: Database, PHP-API, PartiallyScanned, ext:core diff --git a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php index 5db361ea5cf0..6b80dd8704d7 100644 --- a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php +++ b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php @@ -57,6 +57,7 @@ use TYPO3\CMS\Core\Service\FlexFormService; use TYPO3\CMS\Core\Text\TextCropper; use TYPO3\CMS\Core\TimeTracker\TimeTracker; use TYPO3\CMS\Core\Type\BitSet; +use TYPO3\CMS\Core\Type\File\ImageInfo; use TYPO3\CMS\Core\TypoScript\TypoScriptService; use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\CMS\Core\Utility\DebugUtility; @@ -3658,8 +3659,17 @@ class ContentObjectRenderer implements LoggerAwareInterface $gifCreator->start($fileArray, $this->data); $theImage = $gifCreator->gifBuild(); if ($theImage !== '') { - $imageResource = $gifCreator->getGraphicalFunctions()->getImageDimensions(Environment::getPublicPath() . '/' . $theImage); - $imageResource['origFile'] = $theImage; + $fullPath = Environment::getPublicPath() . '/' . $theImage; + $imageInfo = GeneralUtility::makeInstance(ImageInfo::class, $fullPath); + if ($imageInfo->getWidth() > 0) { + $imageResource = [ + 0 => $imageInfo->getWidth(), + 1 => $imageInfo->getHeight(), + 2 => $imageInfo->getExtension(), + 3 => $fullPath, + 'origFile' => $theImage, + ]; + } } } } else { diff --git a/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php b/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php index 67ef814e181f..22a7847dba53 100644 --- a/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php +++ b/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php @@ -383,13 +383,6 @@ final class ContentObjectRendererTest extends UnitTestCase */ public function getImgResourceCallsGetImgResourcePostProcessHook(): void { - $cacheManagerMock = $this->getMockBuilder(CacheManager::class)->disableOriginalConstructor()->getMock(); - $cacheMock = $this->getMockBuilder(CacheFrontendInterface::class)->disableOriginalConstructor()->getMock(); - $cacheMock->method('get')->willReturn(false); - $cacheMock->method('set')->willReturn(false); - $cacheManagerMock->method('getCache')->with('imagesizes')->willReturn($cacheMock); - GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerMock); - $resourceFactory = $this->createMock(ResourceFactory::class); $this->subject->method('getResourceFactory')->willReturn($resourceFactory); diff --git a/typo3/sysext/install/Classes/Configuration/Cache/CustomCachePreset.php b/typo3/sysext/install/Classes/Configuration/Cache/CustomCachePreset.php index 56c57a678ffa..31044c14caf2 100644 --- a/typo3/sysext/install/Classes/Configuration/Cache/CustomCachePreset.php +++ b/typo3/sysext/install/Classes/Configuration/Cache/CustomCachePreset.php @@ -31,7 +31,6 @@ class CustomCachePreset extends AbstractCustomPreset implements CustomPresetInte protected $configurationValues = [ 'SYS/caching/cacheConfigurations/hash/backend' => Typo3DatabaseBackend::class, 'SYS/caching/cacheConfigurations/pages/backend' => Typo3DatabaseBackend::class, - 'SYS/caching/cacheConfigurations/imagesizes/backend' => Typo3DatabaseBackend::class, 'SYS/caching/cacheConfigurations/rootline/backend' => Typo3DatabaseBackend::class, ]; } diff --git a/typo3/sysext/install/Classes/Configuration/Cache/DatabaseCachePreset.php b/typo3/sysext/install/Classes/Configuration/Cache/DatabaseCachePreset.php index 681efefdce85..940dd4bf5c41 100644 --- a/typo3/sysext/install/Classes/Configuration/Cache/DatabaseCachePreset.php +++ b/typo3/sysext/install/Classes/Configuration/Cache/DatabaseCachePreset.php @@ -37,8 +37,6 @@ class DatabaseCachePreset extends AbstractPreset 'SYS/caching/cacheConfigurations/hash/backend' => Typo3DatabaseBackend::class, 'SYS/caching/cacheConfigurations/pages/backend' => Typo3DatabaseBackend::class, 'SYS/caching/cacheConfigurations/pages/options/compression' => true, - 'SYS/caching/cacheConfigurations/imagesizes/backend' => Typo3DatabaseBackend::class, - 'SYS/caching/cacheConfigurations/imagesizes/options/compression' => true, 'SYS/caching/cacheConfigurations/rootline/backend' => Typo3DatabaseBackend::class, 'SYS/caching/cacheConfigurations/rootline/options/compression' => true, ]; diff --git a/typo3/sysext/install/Classes/Configuration/Cache/FileCachePreset.php b/typo3/sysext/install/Classes/Configuration/Cache/FileCachePreset.php index fd53b8ec4bd7..146ff564d3bb 100644 --- a/typo3/sysext/install/Classes/Configuration/Cache/FileCachePreset.php +++ b/typo3/sysext/install/Classes/Configuration/Cache/FileCachePreset.php @@ -16,7 +16,6 @@ namespace TYPO3\CMS\Install\Configuration\Cache; use TYPO3\CMS\Core\Cache\Backend\FileBackend; -use TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend; use TYPO3\CMS\Install\Configuration\AbstractPreset; class FileCachePreset extends AbstractPreset @@ -38,8 +37,6 @@ class FileCachePreset extends AbstractPreset 'SYS/caching/cacheConfigurations/hash/backend' => FileBackend::class, 'SYS/caching/cacheConfigurations/pages/backend' => FileBackend::class, 'SYS/caching/cacheConfigurations/pages/options/compression' => '__UNSET', - 'SYS/caching/cacheConfigurations/imagesizes/backend' => SimpleFileBackend::class, - 'SYS/caching/cacheConfigurations/imagesizes/options/compression' => '__UNSET', 'SYS/caching/cacheConfigurations/rootline/backend' => FileBackend::class, 'SYS/caching/cacheConfigurations/rootline/options/compression' => '__UNSET', ]; diff --git a/typo3/sysext/install/Classes/Controller/EnvironmentController.php b/typo3/sysext/install/Classes/Controller/EnvironmentController.php index 080e1bf3deff..99240ee16781 100644 --- a/typo3/sysext/install/Classes/Controller/EnvironmentController.php +++ b/typo3/sysext/install/Classes/Controller/EnvironmentController.php @@ -32,6 +32,7 @@ use TYPO3\CMS\Core\Mail\MailerInterface; use TYPO3\CMS\Core\Messaging\FlashMessage; use TYPO3\CMS\Core\Messaging\FlashMessageQueue; use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity; +use TYPO3\CMS\Core\Type\File\ImageInfo; use TYPO3\CMS\Core\Utility\CommandUtility; use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -671,11 +672,11 @@ class EnvironmentController extends AbstractController $resultFile = $this->getImagesPath() . $imageService->filenamePrefix . StringUtility::getUniqueId($imageService->alternativeOutputKey . 'combine1') . '.jpg'; $imageService->combineExec($inputFile, $overlayFile, $maskFile, $resultFile); - $imResult = $imageService->getImageDimensions($resultFile); - if ($imResult) { + $imageInfo = GeneralUtility::makeInstance(ImageInfo::class, $resultFile); + if ($imageInfo->getWidth() > 0) { $result = [ 'fileExists' => true, - 'outputFile' => $imResult[3], + 'outputFile' => $resultFile, 'referenceFile' => self::TEST_REFERENCE_PATH . '/Combine-1.jpg', 'command' => $imageService->IM_commands, ]; @@ -707,11 +708,11 @@ class EnvironmentController extends AbstractController $resultFile = $this->getImagesPath() . $imageService->filenamePrefix . StringUtility::getUniqueId($imageService->alternativeOutputKey . 'combine2') . '.jpg'; $imageService->combineExec($inputFile, $overlayFile, $maskFile, $resultFile); - $imResult = $imageService->getImageDimensions($resultFile); - if ($imResult) { + $imageInfo = GeneralUtility::makeInstance(ImageInfo::class, $resultFile); + if ($imageInfo->getWidth() > 0) { $result = [ 'fileExists' => true, - 'outputFile' => $imResult[3], + 'outputFile' => $resultFile, 'referenceFile' => self::TEST_REFERENCE_PATH . '/Combine-2.jpg', 'command' => $imageService->IM_commands, ]; @@ -742,10 +743,9 @@ class EnvironmentController extends AbstractController $gifBuilder->makeBox($image, $conf, $workArea); $outputFile = $this->getImagesPath() . $gifBuilder->getGraphicalFunctions()->filenamePrefix . StringUtility::getUniqueId('gdSimple') . '.' . $gifOrPng; $gifBuilder->ImageWrite($image, $outputFile); - $imResult = $gifBuilder->getGraphicalFunctions()->getImageDimensions($outputFile); $result = [ 'fileExists' => true, - 'outputFile' => $imResult[3], + 'outputFile' => $outputFile, 'referenceFile' => self::TEST_REFERENCE_PATH . '/Gdlib-simple.' . $gifOrPng, 'command' => $gifBuilder->getGraphicalFunctions()->IM_commands, ]; @@ -770,10 +770,9 @@ class EnvironmentController extends AbstractController $gifBuilder->makeBox($image, $conf, $workArea); $outputFile = $this->getImagesPath() . $gifBuilder->getGraphicalFunctions()->filenamePrefix . StringUtility::getUniqueId('gdBox') . '.' . $gifOrPng; $gifBuilder->ImageWrite($image, $outputFile); - $imResult = $gifBuilder->getGraphicalFunctions()->getImageDimensions($outputFile); $result = [ 'fileExists' => true, - 'outputFile' => $imResult[3], + 'outputFile' => $outputFile, 'referenceFile' => self::TEST_REFERENCE_PATH . '/Gdlib-box.' . $gifOrPng, 'command' => $gifBuilder->getGraphicalFunctions()->IM_commands, ]; @@ -805,10 +804,9 @@ class EnvironmentController extends AbstractController $gifBuilder->makeText($image, $conf, $workArea); $outputFile = $this->getImagesPath() . $gifBuilder->getGraphicalFunctions()->filenamePrefix . StringUtility::getUniqueId('gdText') . '.' . $gifOrPng; $gifBuilder->ImageWrite($image, $outputFile); - $imResult = $gifBuilder->getGraphicalFunctions()->getImageDimensions($outputFile); $result = [ 'fileExists' => true, - 'outputFile' => $imResult[3], + 'outputFile' => $outputFile, 'referenceFile' => self::TEST_REFERENCE_PATH . '/Gdlib-text.' . $gifOrPng, 'command' => $gifBuilder->getGraphicalFunctions()->IM_commands, ]; @@ -851,10 +849,9 @@ class EnvironmentController extends AbstractController $gifBuilder->makeText($image, $conf, $workArea); $outputFile = $this->getImagesPath() . $gifBuilder->getGraphicalFunctions()->filenamePrefix . StringUtility::getUniqueId('gdNiceText') . '.' . $gifOrPng; $gifBuilder->ImageWrite($image, $outputFile); - $imResult = $gifBuilder->getGraphicalFunctions()->getImageDimensions($outputFile); $result = [ 'fileExists' => true, - 'outputFile' => $imResult[3], + 'outputFile' => $outputFile, 'referenceFile' => self::TEST_REFERENCE_PATH . '/Gdlib-niceText.' . $gifOrPng, 'command' => $gifBuilder->getGraphicalFunctions()->IM_commands, ]; @@ -910,10 +907,9 @@ class EnvironmentController extends AbstractController $gifBuilder->makeText($image, $conf, $workArea); $outputFile = $this->getImagesPath() . $gifBuilder->getGraphicalFunctions()->filenamePrefix . StringUtility::getUniqueId('GDwithText-niceText-shadow') . '.' . $gifOrPng; $gifBuilder->ImageWrite($image, $outputFile); - $imResult = $gifBuilder->getGraphicalFunctions()->getImageDimensions($outputFile); $result = [ 'fileExists' => true, - 'outputFile' => $imResult[3], + 'outputFile' => $outputFile, 'referenceFile' => self::TEST_REFERENCE_PATH . '/Gdlib-shadow.' . $gifOrPng, 'command' => $gifBuilder->getGraphicalFunctions()->IM_commands, ]; diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php index a4a723506691..5fd6e66e5751 100644 --- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php +++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php @@ -6059,4 +6059,18 @@ return [ 'Breaking-101955-RemovedPublicMethodsRelatedToImageGeneration.rst', ], ], + 'TYPO3\CMS\Core\Imaging\GraphicalFunctions->getCachedImageDimensions' => [ + 'numberOfMandatoryArguments' => 1, + 'maximumNumberOfArguments' => 1, + 'restFiles' => [ + 'Breaking-102009-ImagesizesCacheRemoved.rst', + ], + ], + 'TYPO3\CMS\Core\Imaging\GraphicalFunctions->cacheImageDimensions' => [ + 'numberOfMandatoryArguments' => 1, + 'maximumNumberOfArguments' => 1, + 'restFiles' => [ + 'Breaking-102009-ImagesizesCacheRemoved.rst', + ], + ], ]; -- GitLab