TT#89200 fix workaround logic for backward-incompatible prefs

Change-Id: I2485d8cc4852fa83ee783c88e5a20b3dc884f666
mr9.0
Rene Krenn 5 years ago
parent 116d092cbe
commit 543533bde3

@ -327,7 +327,7 @@ sub prepare_resource {
$value = $pref->value;
} # SWITCH
eval {
$value = _api_transform_out($c, $pref->attribute, $pref->value);
$value = _api_transform_out($c, $pref->attribute, $value);
};
if ($@) {
$c->log->error("Failed to transform pref value - $@");
@ -1001,14 +1001,20 @@ sub _api_transform_out {
if ($c->request and $c->request->path =~/^api\//i) {
$API_TRANSFORM_OUT = _init_transform($API_TRANSFORM_OUT,$c->config->{preference_out_transformations});
if (exists $API_TRANSFORM_OUT->{$meta->attribute}) {
if (defined $value and exists $API_TRANSFORM_OUT->{$meta->attribute}->{$value}) {
$value = $API_TRANSFORM_OUT->{$meta->attribute}->{$value};
if ('CODE' eq ref $value) {
eval {
$value = $value->($meta,$value);
};
if ($@) {
die($meta->attribute . ": " . $@);
if (defined $value) {
my $v = $value;
if (JSON::is_bool($v)) {
$v = $v ? 1 : 0 ;
}
if (exists $API_TRANSFORM_OUT->{$meta->attribute}->{$v}) {
$value = $API_TRANSFORM_OUT->{$meta->attribute}->{$v};
if ('CODE' eq ref $value) {
eval {
$value = $value->($meta,$value);
};
if ($@) {
die($meta->attribute . ": " . $@);
}
}
}
}

Loading…
Cancel
Save