Browse Source

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 <tomascohen@theke.io>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
20.05.x
Tomás Cohen Arazi 3 years ago
committed by Martin Renvoize
parent
commit
d5e993ed47
Signed by: martin.renvoize GPG Key ID: 422B469130441A0F
  1. 10
      Koha/Biblio.pm

10
Koha/Biblio.pm

@ -791,16 +791,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 };
}

Loading…
Cancel
Save