Commit 0c5436ae authored by Mathias Brodala's avatar Mathias Brodala Committed by Markus Klein
Browse files

[TASK] Migrate "GFX/processor_effects" to boolean

Ensure "GFX/processor_effects" is a true boolean as suggested in
the settings module and silently migrate integer/string values
accordingly.

Resolves: #83591
Releases: master
Change-Id: I006e907e75e273009333363a4d42661183ba8721
Reviewed-on: https://review.typo3.org/57391


Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Frans Saris's avatarFrans Saris <franssaris@gmail.com>
Reviewed-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
parent ad9da640
......@@ -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' => '',
];
......
......@@ -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',
];
......
......@@ -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',
];
......
......@@ -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;
}
......
......@@ -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:
......
......@@ -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
*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment