Bug 29523: (QA follow-up) Catch remaining SUPER::to_api cases

Koha::Object->to_api can now return undefined.. we should be catching
that cases in all post manipulation cases.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Martin Renvoize 2021-11-26 13:40:15 +00:00 committed by Tomas Cohen Arazi
parent bbd153d688
commit ca2dd193fc
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
5 changed files with 19 additions and 12 deletions

View File

@ -250,13 +250,14 @@ suitable for API output.
sub to_api {
my ( $self, $params ) = @_;
my $json = $self->SUPER::to_api( $params );
my $json_basket = $self->SUPER::to_api( $params );
return unless $json_basket;
$json->{closed} = ( $self->closedate )
$json_basket->{closed} = ( $self->closedate )
? Mojo::JSON->true
: Mojo::JSON->false;
return $json;
return $json_basket;
}
=head3 to_api_mapping

View File

@ -62,6 +62,8 @@ sub to_api {
my $budget_period_id = $self->budget_period_id;
my $json_fund = $self->SUPER::to_api($args);
return unless $json_fund;
$json_fund->{fund_id} = $budget_id;
$json_fund->{budget_id} = $budget_period_id;

View File

@ -41,13 +41,14 @@ suitable for API output.
sub to_api {
my ( $self, $params ) = @_;
my $json = $self->SUPER::to_api( $params );
my $json_invoice = $self->SUPER::to_api( $params );
return unless $json_invoice;
$json->{closed} = ( $self->closedate )
$json_invoice->{closed} = ( $self->closedate )
? Mojo::JSON->true
: Mojo::JSON->false;
return $json;
return $json_invoice;
}
=head3 to_api_mapping

View File

@ -1424,14 +1424,16 @@ on the API.
sub to_api {
my ($self, $args) = @_;
my $response = $self->SUPER::to_api( $args );
my $json_biblio = $self->SUPER::to_api( $args );
return unless $json_biblio;
$args = defined $args ? {%$args} : {};
delete $args->{embed};
my $biblioitem = $self->biblioitem->to_api( $args );
my $json_biblioitem = $self->biblioitem->to_api( $args );
return unless $json_biblioitem;
return { %$response, %$biblioitem };
return { %$json_biblio, %$json_biblioitem };
}
=head3 to_api_mapping

View File

@ -135,10 +135,11 @@ suitable for API output.
sub to_api {
my ( $self, $params ) = @_;
my $json = $self->SUPER::to_api( $params );
delete $json->{password};
my $json_smtp = $self->SUPER::to_api( $params );
return unless $json_smtp;
delete $json_smtp->{password};
return $json;
return $json_smtp;
}
=head3 to_api_mapping