From 7c25d295731840df5ec5e16b9284296abf7ff4bd Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 31 Jan 2020 09:06:51 -0300 Subject: [PATCH] Bug 24554: Only embed relations from Koha::Biblio in to_api This patch simplifies the behaviour of Koha::Biblio->to_api. It was designed with the idea of handling possible methods that would be added to Koha::Biblioitem. But it had a weird fallback behaviour was highlighted by using it with bug 24528. On fixing it it become obvious that it was unnessessarily complex and that it was not worth. That's the reason there wasn't any test for it, as Koha::Biblioitem doesn't implement any extra methods. To test: 1. Run: $ kshell k$ prove t/db_dependent/Koha/Biblio.t => SUCCESS: Tests pass 2. Apply this patch 3. Repeat (1) => SUCCESS: Tests pass! 4. Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: David Nind --- Koha/Biblio.pm | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index d5fe1f9fa6..9ddfa0c910 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -785,16 +785,8 @@ on the API. sub to_api { my ($self, $args) = @_; - my @embeds = keys %{ $args->{embed} }; - my $remaining_embeds = {}; - - foreach my $embed (@embeds) { - $remaining_embeds = delete $args->{embed}->{$embed} - unless $self->can($embed); - } - my $response = $self->SUPER::to_api( $args ); - my $biblioitem = $self->biblioitem->to_api({ embed => $remaining_embeds }); + my $biblioitem = $self->biblioitem->to_api; return { %$response, %$biblioitem }; } -- 2.11.0