From 4f705636c2c5dd85be9dd664fae6285327627f98 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. --- 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 0f179044ebc..54163dd9b54 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 20c8ecca045..d1b921e00c3 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.34.1