diff --git a/Koha/Old/Checkouts.pm b/Koha/Old/Checkouts.pm index 5ba2bec6d2..8ee651645f 100644 --- a/Koha/Old/Checkouts.pm +++ b/Koha/Old/Checkouts.pm @@ -96,7 +96,10 @@ Anonymize the given I resultset. sub anonymize { my ( $self, $params ) = @_; - my $anonymous_id = C4::Context->preference('AnonymousPatron') || undef; + my $anonymous_id = C4::Context->preference('AnonymousPatron'); + + Koha::Exceptions::SysPref::NotSet->throw( syspref => 'AnonymousPatron' ) + unless $anonymous_id; return $self->update( { borrowernumber => $anonymous_id }, { no_triggers => 1 } ); } diff --git a/Koha/Old/Hold.pm b/Koha/Old/Hold.pm index 33642b33f6..aa164fcd2a 100644 --- a/Koha/Old/Hold.pm +++ b/Koha/Old/Hold.pm @@ -22,6 +22,7 @@ use Modern::Perl; use base qw(Koha::Hold); use C4::Context; +use Koha::Exceptions::SysPref; =head1 NAME @@ -44,7 +45,10 @@ Anonymize the given I object. sub anonymize { my ($self) = @_; - my $anonymous_id = C4::Context->preference('AnonymousPatron') || undef; + my $anonymous_id = C4::Context->preference('AnonymousPatron'); + + Koha::Exceptions::SysPref::NotSet->throw( syspref => 'AnonymousPatron' ) + unless $anonymous_id; return $self->update( { borrowernumber => $anonymous_id } ); } diff --git a/Koha/Old/Holds.pm b/Koha/Old/Holds.pm index 1a7cb0d5a7..d3aad2ee89 100644 --- a/Koha/Old/Holds.pm +++ b/Koha/Old/Holds.pm @@ -78,7 +78,10 @@ Anonymize the given I resultset. sub anonymize { my ( $self, $params ) = @_; - my $anonymous_id = C4::Context->preference('AnonymousPatron') || undef; + my $anonymous_id = C4::Context->preference('AnonymousPatron'); + + Koha::Exceptions::SysPref::NotSet->throw( syspref => 'AnonymousPatron' ) + unless $anonymous_id; return $self->update( { borrowernumber => $anonymous_id }, { no_triggers => 1 } ); }