From c7786b419cdaadc710a81a288aacf76fe8fd8b97 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 12 Sep 2024 12:35:33 +0200 Subject: [PATCH] Bug 37902: TODOs There are still different structures we won't handle properly. This patch adds conditionals to prevent failures or warnings. Should be done, but later. Signed-off-by: Nick Clemens Signed-off-by: Kyle M Hall Signed-off-by: Katrin Fischer --- Koha/Object.pm | 13 ++++++++++++- Koha/REST/Plugin/Objects.pm | 5 +++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Koha/Object.pm b/Koha/Object.pm index 0f179044eb..54163dd9b5 100644 --- a/Koha/Object.pm +++ b/Koha/Object.pm @@ -878,13 +878,24 @@ sub attributes_from_api { my $params; my $columns_info = $self->_result->result_source->columns_info; + if ( ref($from_api_params) && ref($from_api_params) eq 'ARRAY' ) { + # TODO No fixup if an ARRAY is passed + return $from_api_params; + } + while ( my ( $key, $value ) = each %{$from_api_params} ) { my $koha_field_name = exists $from_api_mapping->{$key} ? $from_api_mapping->{$key} : $key; - $params->{$koha_field_name} = $self->_recursive_fixup( $key, $value, $columns_info->{$koha_field_name} ); + if ( exists $columns_info->{$koha_field_name} ) { + # TODO No fixup if the name is from an embed (eg. suggester.borrowernumber) + # See warnings produced by t/db_dependent/Koha/REST/Plugin/Objects.t if this test is removed + $params->{$koha_field_name} = $self->_recursive_fixup( $key, $value, $columns_info->{$koha_field_name} ); + } else { + $params->{$koha_field_name} = $value; + } } return $params; diff --git a/Koha/REST/Plugin/Objects.pm b/Koha/REST/Plugin/Objects.pm index 20c8ecca04..d1b921e00c 100644 --- a/Koha/REST/Plugin/Objects.pm +++ b/Koha/REST/Plugin/Objects.pm @@ -284,8 +284,9 @@ controller, and thus shouldn't be called twice in it. ); } - $filtered_params = - $result_set->attributes_from_api($filtered_params); + if ( defined $filtered_params ) { + $filtered_params = $result_set->attributes_from_api($filtered_params); + } $c->dbic_validate_operators( { filtered_params => $filtered_params } ); -- 2.39.5