diff --git a/Koha/Object.pm b/Koha/Object.pm index 2b1d2e2938..12b16eb8d7 100644 --- a/Koha/Object.pm +++ b/Koha/Object.pm @@ -551,6 +551,9 @@ Returns a representation of the object, suitable for API output. sub to_api { my ( $self, $params ) = @_; + + return unless $self->accessible; + my $json_object = $self->TO_JSON; # Make sure we duplicate the $params variable to avoid diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 902c6995d3..4e63c4f261 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -2288,6 +2288,8 @@ sub to_api { my $json_patron = $self->SUPER::to_api( $params ); + return unless $json_patron; + $json_patron->{restricted} = ( $self->is_debarred ) ? Mojo::JSON->true : Mojo::JSON->false;