Skip to content

Commit

Permalink
[BUGFIX] Use custom image file extensions for image processing tests
Browse files Browse the repository at this point in the history
If an integrator removes image file extensions, e.g. "gif", from
$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] the whole image
processing test in the install tool fails.

That's because some tests need to run independent of the global
configuration. Therefore the GraphicalFunctions class, which is
used as the image processor, now features a setter. This allows
EXT:install to manually define required image extensions for the
tests, which should not consider the global configuration.

Note: The `convertImageFormatsToJpg` test, which tries to
convert every defined image file extension (based on the
global configuration) to JPG, is not affected by this change.

Resolves: #92958
Releases: master, 10.4
Change-Id: Ic84be73c897f497fedd6b442965edf6fb3ef88c3
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/67344
Tested-by: Oliver Bartsch <bo@cedev.de>
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Martin Kutschker <mkutschker-typo3@yahoo.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Martin Kutschker <mkutschker-typo3@yahoo.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
  • Loading branch information
brandung-gs authored and lolli42 committed Jan 6, 2021
1 parent 73c8134 commit 93ac43c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
9 changes: 9 additions & 0 deletions typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1192,6 +1192,15 @@ public function getTextScalFactor($conf)
return $sF;
}

/**
* @param array $imageFileExt
* @internal Only used for ext:install, not part of TYPO3 Core API.
*/
public function setImageFileExt(array $imageFileExt): void
{
$this->imageFileExt = $imageFileExt;
}

/**
* Renders a regular text and takes care of a possible line break automatically.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
*/
class EnvironmentController extends AbstractController
{
private const IMAGE_FILE_EXT = ['gif', 'jpg', 'png', 'tif', 'ai', 'pdf'];

/**
* @var LateBootService
*/
Expand Down Expand Up @@ -911,6 +913,7 @@ protected function initializeImageProcessor(): GraphicalFunctions
$imageProcessor->filenamePrefix = 'installTool-';
$imageProcessor->dontCompress = true;
$imageProcessor->alternativeOutputKey = 'typo3InstallTest';
$imageProcessor->setImageFileExt(self::IMAGE_FILE_EXT);
return $imageProcessor;
}

Expand Down Expand Up @@ -1086,10 +1089,10 @@ protected function getImageTestResponse(array $testResult): ResponseInterface
'success' => true,
];
foreach ($testResult as $resultKey => $value) {
if ($resultKey === 'referenceFile') {
if ($resultKey === 'referenceFile' && !empty($testResult['referenceFile'])) {
$fileExt = end(explode('.', $testResult['referenceFile']));
$responseData['referenceFile'] = 'data:image/' . $fileExt . ';base64,' . base64_encode((string)file_get_contents($testResult['referenceFile']));
} elseif ($resultKey === 'outputFile') {
} elseif ($resultKey === 'outputFile' && !empty($testResult['outputFile'])) {
$fileExt = end(explode('.', $testResult['outputFile']));
$responseData['outputFile'] = 'data:image/' . $fileExt . ';base64,' . base64_encode((string)file_get_contents($testResult['outputFile']));
} else {
Expand Down

0 comments on commit 93ac43c

Please sign in to comment.