Skip to content

Commit

Permalink
pkp#6186 If the field is multilingual, but doesn't have a default val…
Browse files Browse the repository at this point in the history
…ue, it still need to be decoded

(cherry picked from commit 224509c)
(cherry picked from commit 81def38)
  • Loading branch information
jonasraoni committed Apr 26, 2024
1 parent 6517cad commit b687fc3
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion classes/plugins/ThemePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ public function getOptionValues($contextId)
break;
case 'array':
try {
$value = json_decode($value, true, flags: JSON_THROW_ON_ERROR);
$value = json_decode((string) $value, true, flags: JSON_THROW_ON_ERROR);
} catch (Exception) {
// FIXME: pkp/pkp-lib#6250 Remove after 3.3.x upgrade code is removed (see also pkp/pkp-lib#5772)
$value = unserialize($value);
Expand All @@ -588,6 +588,16 @@ public function getOptionValues($contextId)
break;
}
}
// If the value isn't null and it's a multilingual field, then we must ensure it's an array
if ($optionConfig->isMultilingual && $value !== null && !is_array($value)) {
try {
$value = json_decode((string) $value, true, flags: JSON_THROW_ON_ERROR);
} catch (Exception) {
// FIXME: pkp/pkp-lib#6250 Remove after 3.3.x upgrade code is removed (see also pkp/pkp-lib#5772)
$value = unserialize($value);
}
$value = is_array($value) ? $value : [];
}
$return[$optionName] = $value;
}

Expand Down

0 comments on commit b687fc3

Please sign in to comment.