Skip to content

Commit

Permalink
OXDEV-7325: Remove handling of empty strings as arrays in database
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelOxid committed Dec 6, 2023
1 parent 870c76c commit c5c0e3d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
4 changes: 0 additions & 4 deletions src/Setting/Infrastructure/ShopSettingRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,6 @@ public function getArrayFromSettingValue(ShopConfigurationSetting $setting): arr
{
$value = $setting->getValue();

if ($value === '') {
$value = [];
}

if (!is_array($value)) {
throw new WrongSettingValueException();
}
Expand Down
4 changes: 0 additions & 4 deletions src/Setting/Infrastructure/ThemeSettingRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@ public function getAssocCollection(string $name, string $themeId): array
*/
public function getArrayFromSettingValue(mixed $value): array
{
if ($value === '') {
$value = [];
}

if (!is_array($value)) {
throw new WrongSettingValueException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,6 @@ public function possibleGetFloatValuesDataProvider(): \Generator

public function possibleGetAssocCollectionValuesDataProvider(): \Generator
{
yield 'empty string for assoc collection' => [
'method' => 'getAssocCollection',
'type' => FieldType::ASSOCIATIVE_ARRAY,
'possibleValue' => '',
'expectedResult' => []
];

yield 'empty array for assoc collection' => [
'method' => 'getAssocCollection',
'type' => FieldType::ASSOCIATIVE_ARRAY,
Expand Down Expand Up @@ -225,13 +218,6 @@ public function possibleGetStringValuesDataProvider(): \Generator

public function possibleGetCollectionValuesDataProvider(): \Generator
{
yield 'empty string collection' => [
'method' => 'getCollection',
'type' => FieldType::ARRAY,
'possibleValue' => '',
'expectedResult' => []
];

yield 'empty array collection' => [
'method' => 'getCollection',
'type' => FieldType::ARRAY,
Expand Down Expand Up @@ -298,6 +284,13 @@ public function wrongSettingsValueDataProvider(): \Generator
'expectedResult' => WrongSettingValueException::class
];

yield 'empty string instead of collection' => [
'method' => 'getCollection',
'type' => FieldType::ARRAY,
'possibleValue' => '',
'expectedResult' => WrongSettingValueException::class
];

yield 'string instead of collection' => [
'method' => 'getCollection',
'type' => FieldType::ARRAY,
Expand Down Expand Up @@ -326,6 +319,13 @@ public function wrongSettingsValueDataProvider(): \Generator
'expectedResult' => WrongSettingValueException::class
];

yield 'empty string instead of assoc collection' => [
'method' => 'getAssocCollection',
'type' => FieldType::ASSOCIATIVE_ARRAY,
'possibleValue' => '',
'expectedResult' => WrongSettingValueException::class
];

yield 'false as the error result of unserialize in assoc collection' => [
'method' => 'getAssocCollection',
'type' => FieldType::ASSOCIATIVE_ARRAY,
Expand Down

0 comments on commit c5c0e3d

Please sign in to comment.