diff --git a/typo3/sysext/install/Classes/Configuration/Image/CustomPreset.php b/typo3/sysext/install/Classes/Configuration/Image/CustomPreset.php index d408494cdb7c8491615c0e16f2d3c8724b4c9584..5e3d0e121f48d689acc2478b8d6fd8385cf18847 100644 --- a/typo3/sysext/install/Classes/Configuration/Image/CustomPreset.php +++ b/typo3/sysext/install/Classes/Configuration/Image/CustomPreset.php @@ -29,7 +29,7 @@ class CustomPreset extends Configuration\AbstractCustomPreset implements Configu 'GFX/processor_path' => '', 'GFX/processor_path_lzw' => '', 'GFX/processor' => '', - 'GFX/processor_effects' => 0, + 'GFX/processor_effects' => false, 'GFX/processor_allowTemporaryMasksAsPng' => true, 'GFX/processor_colorspace' => '', ]; diff --git a/typo3/sysext/install/Classes/Configuration/Image/GraphicsMagickPreset.php b/typo3/sysext/install/Classes/Configuration/Image/GraphicsMagickPreset.php index e289af86f0f1ba4ba8e051618b7cd69236959ba5..410163f525f925c24978fe2345ea46ea33223a14 100644 --- a/typo3/sysext/install/Classes/Configuration/Image/GraphicsMagickPreset.php +++ b/typo3/sysext/install/Classes/Configuration/Image/GraphicsMagickPreset.php @@ -40,7 +40,7 @@ class GraphicsMagickPreset extends AbstractImagePreset 'GFX/processor_path' => '', 'GFX/processor_path_lzw' => '', 'GFX/processor' => 'GraphicsMagick', - 'GFX/processor_effects' => -1, + 'GFX/processor_effects' => false, 'GFX/processor_allowTemporaryMasksAsPng' => false, 'GFX/processor_colorspace' => 'RGB', ]; diff --git a/typo3/sysext/install/Classes/Configuration/Image/ImageMagick6Preset.php b/typo3/sysext/install/Classes/Configuration/Image/ImageMagick6Preset.php index 504e0593b170913bafcd23b263f8829512ccc8b9..b528ecdced7e40c05aa711c5e3953b1403550790 100644 --- a/typo3/sysext/install/Classes/Configuration/Image/ImageMagick6Preset.php +++ b/typo3/sysext/install/Classes/Configuration/Image/ImageMagick6Preset.php @@ -40,7 +40,7 @@ class ImageMagick6Preset extends AbstractImagePreset 'GFX/processor_path' => '', 'GFX/processor_path_lzw' => '', 'GFX/processor' => 'ImageMagick', - 'GFX/processor_effects' => 1, + 'GFX/processor_effects' => true, 'GFX/processor_allowTemporaryMasksAsPng' => false, 'GFX/processor_colorspace' => 'sRGB', ]; diff --git a/typo3/sysext/install/Classes/Service/SilentConfigurationUpgradeService.php b/typo3/sysext/install/Classes/Service/SilentConfigurationUpgradeService.php index 4cad8be3652b5ca3df82710c1d463c7feae07068..7beb55f5d8d9752eeba584ae23edc7f02cbfb0f9 100644 --- a/typo3/sysext/install/Classes/Service/SilentConfigurationUpgradeService.php +++ b/typo3/sysext/install/Classes/Service/SilentConfigurationUpgradeService.php @@ -433,21 +433,21 @@ class SilentConfigurationUpgradeService { $changedValues = []; try { - $currentImValue = $this->configurationManager->getLocalConfigurationValueByPath('GFX/processor_enabled'); + $currentEnabledValue = $this->configurationManager->getLocalConfigurationValueByPath('GFX/processor_enabled'); } catch (MissingArrayPathException $e) { - $currentImValue = $this->configurationManager->getDefaultConfigurationValueByPath('GFX/processor_enabled'); + $currentEnabledValue = $this->configurationManager->getDefaultConfigurationValueByPath('GFX/processor_enabled'); } try { - $currentImPathValue = $this->configurationManager->getLocalConfigurationValueByPath('GFX/processor_path'); + $currentPathValue = $this->configurationManager->getLocalConfigurationValueByPath('GFX/processor_path'); } catch (MissingArrayPathException $e) { - $currentImPathValue = $this->configurationManager->getDefaultConfigurationValueByPath('GFX/processor_path'); + $currentPathValue = $this->configurationManager->getDefaultConfigurationValueByPath('GFX/processor_path'); } try { - $currentImPathLzwValue = $this->configurationManager->getLocalConfigurationValueByPath('GFX/processor_path_lzw'); + $currentPathLzwValue = $this->configurationManager->getLocalConfigurationValueByPath('GFX/processor_path_lzw'); } catch (MissingArrayPathException $e) { - $currentImPathLzwValue = $this->configurationManager->getDefaultConfigurationValueByPath('GFX/processor_path_lzw'); + $currentPathLzwValue = $this->configurationManager->getDefaultConfigurationValueByPath('GFX/processor_path_lzw'); } try { @@ -462,11 +462,11 @@ class SilentConfigurationUpgradeService $currentThumbnailsValue = $this->configurationManager->getDefaultConfigurationValueByPath('GFX/thumbnails'); } - if (!$currentImValue) { - if ($currentImPathValue != '') { + if (!$currentEnabledValue) { + if ($currentPathValue != '') { $changedValues['GFX/processor_path'] = ''; } - if ($currentImPathLzwValue != '') { + if ($currentPathLzwValue != '') { $changedValues['GFX/processor_path_lzw'] = ''; } if ($currentImageFileExtValue !== 'gif,jpg,jpeg,png') { @@ -512,6 +512,10 @@ class SilentConfigurationUpgradeService } if ((string)$currentProcessorValue !== '') { + if (!is_bool($currentProcessorEffectsValue)) { + $changedValues['GFX/processor_effects'] = (int)$currentProcessorEffectsValue > 0; + } + if ($currentProcessorMaskValue != 0) { $changedValues['GFX/processor_allowTemporaryMasksAsPng'] = 0; } diff --git a/typo3/sysext/install/Resources/Public/Images/TestReference/About.txt b/typo3/sysext/install/Resources/Public/Images/TestReference/About.txt index d0feeb6b034d01ea0f7c2fc3fa0c3de8ea0d63af..5220611232cf5619818911c4411205bdea8ea5cb 100644 --- a/typo3/sysext/install/Resources/Public/Images/TestReference/About.txt +++ b/typo3/sysext/install/Resources/Public/Images/TestReference/About.txt @@ -10,7 +10,7 @@ $TYPO3_CONF_VARS['GFX']['TTFdpi'] = '96'; $TYPO3_CONF_VARS['GFX']['gdlib_png'] = '1'; $TYPO3_CONF_VARS['GFX']['processor_path'] = '/usr/bin/'; $TYPO3_CONF_VARS['GFX']['processor'] = 'im5'; -$TYPO3_CONF_VARS['GFX']['processor_effects'] = '1'; +$TYPO3_CONF_VARS['GFX']['processor_effects'] = true; $TYPO3_CONF_VARS['GFX']['gdlib_2'] = 1; - PHP / GD configuration: diff --git a/typo3/sysext/install/Tests/Unit/Service/SilentConfigurationUpgradeServiceTest.php b/typo3/sysext/install/Tests/Unit/Service/SilentConfigurationUpgradeServiceTest.php index d5427c610849b442668ab19d6ec9cb9565728b0b..047898043b442f0c4b18fcd05a53cd6fcda80b47 100644 --- a/typo3/sysext/install/Tests/Unit/Service/SilentConfigurationUpgradeServiceTest.php +++ b/typo3/sysext/install/Tests/Unit/Service/SilentConfigurationUpgradeServiceTest.php @@ -537,7 +537,7 @@ class SilentConfigurationUpgradeServiceTest extends UnitTestCase $currentLocalConfiguration = [ ['GFX/processor', 'GraphicsMagick'], ['GFX/processor_allowTemporaryMasksAsPng', 1], - ['GFX/processor_effects', 0] + ['GFX/processor_effects', false], ]; $this->createConfigurationManagerWithMockedMethods( [ @@ -553,9 +553,11 @@ class SilentConfigurationUpgradeServiceTest extends UnitTestCase ->method('getDefaultConfigurationValueByPath'); $this->configurationManager->expects($this->once()) ->method('setLocalConfigurationValuesByPathValuePairs') - ->withConsecutive( - [['GFX/processor_allowTemporaryMasksAsPng' => 0]] - ); + ->withConsecutive([ + [ + 'GFX/processor_allowTemporaryMasksAsPng' => 0, + ] + ]); $this->expectException(ConfigurationChangedException::class); @@ -581,7 +583,7 @@ class SilentConfigurationUpgradeServiceTest extends UnitTestCase $currentLocalConfiguration = [ ['GFX/processor', ''], ['GFX/processor_allowTemporaryMasksAsPng', 0], - ['GFX/processor_effects', 0] + ['GFX/processor_effects', 0], ]; $this->createConfigurationManagerWithMockedMethods( [ @@ -603,6 +605,64 @@ class SilentConfigurationUpgradeServiceTest extends UnitTestCase $silentConfigurationUpgradeServiceInstance->_call('setImageMagickDetailSettings'); } + /** + * @test + * @dataProvider graphicsProcessorEffects + * + * @param mixed $currentValue + * @param bool $expectedMigratedValue + */ + public function migratesGraphicsProcessorEffects($currentValue, $expectedMigratedValue) + { + /** @var ConfigurationManager|\Prophecy\Prophecy\ObjectProphecy */ + $configurationManager = $this->prophesize(ConfigurationManager::class); + $configurationManager->getLocalConfigurationValueByPath('GFX/processor')->willReturn('GraphicsMagick'); + $configurationManager->getLocalConfigurationValueByPath('GFX/processor_allowTemporaryMasksAsPng')->willReturn(false); + $configurationManager->getLocalConfigurationValueByPath('GFX/processor_effects')->willReturn($currentValue); + $configurationManager->setLocalConfigurationValuesByPathValuePairs([ + 'GFX/processor_effects' => $expectedMigratedValue, + ])->shouldBeCalled(); + + $this->expectException(ConfigurationChangedException::class); + + $silentConfigurationUpgradeService = new SilentConfigurationUpgradeService($configurationManager->reveal()); + + $this->callInaccessibleMethod($silentConfigurationUpgradeService, 'setImageMagickDetailSettings'); + } + + /** + * @return array + */ + public function graphicsProcessorEffects(): array + { + return [ + 'integer 1' => [ + 1, + true, + ], + 'integer 0' => [ + 0, + false, + ], + 'integer -1' => [ + -1, + false, + ], + 'string "1"' => [ + '1', + true, + ], + 'string "0"' => [ + '0', + false, + ], + 'string "-1"' => [ + '-1', + false, + ], + ]; + } + /** * @test */