Bug 30007: Make ->anonymize methods throw an exception if AnonymousPatron is not set
This patch makes the ->anonymize methods throw a
Koha::Exceptions::SysPref::NotSet exception when trying to anonymize
holds and checkouts without AnonymousPatron properly set.
To test:
1. Apply the regression tests patch
2. Run:
$ kshell
k$ prove t/db_dependent/Koha/Old/Checkouts.t \
t/db_dependent/Koha/Old/Holds.t \
t/db_dependent/Koha/Old/Hold.t
=> FAIL: Tests fail, no exception thrown
3. Apply this patch
4. Repeat 2
=> SUCCESS: Tests pass!
5. Sign off :-D
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
https://bugs.koha-community.org/show_bug.cgi?id=3007
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
parent
7ebeb58bfd
commit
c4e5e04f57
|
|
@ -96,7 +96,10 @@ Anonymize the given I<Koha::Old::Checkouts> 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 } );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Koha::Old::Hold> 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 } );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,10 @@ Anonymize the given I<Koha::Old::Holds> 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 } );
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue