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 } );