Bugzilla – Attachment 183969 Details for
Bug 40337
checkprevcheckout must be defined as ENUM at DB level
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40337: Handle enum in Koha::Patron->anonymize
Bug-40337-Handle-enum-in-KohaPatron-anonymize.patch (text/plain), 3.02 KB, created by
Jonathan Druart
on 2025-07-10 19:56:56 UTC
(
hide
)
Description:
Bug 40337: Handle enum in Koha::Patron->anonymize
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2025-07-10 19:56:56 UTC
Size:
3.02 KB
patch
obsolete
>From 9ed1f74bcf89d87065138538efb0019843c23aaa Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 10 Jul 2025 21:55:05 +0200 >Subject: [PATCH] Bug 40337: Handle enum in Koha::Patron->anonymize > >We need to reset to the default value. We might have a problem (later) >if it's NOT NULL and no default is set, which is not handled by this >patch. But the situation does not seem to exist yet anyway. >--- > Koha/Patron.pm | 2 ++ > t/db_dependent/Koha/Patrons.t | 17 +++++++++-------- > 2 files changed, 11 insertions(+), 8 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 14d5838e6be..ecfe7d40bb4 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -2677,6 +2677,8 @@ sub _anonymize_column { > $val = $nullable ? undef : 0; > } elsif ( $type =~ /date|time/ ) { > $val = $nullable ? undef : dt_from_string; >+ } elsif ( $type eq 'enum' ) { >+ $val = $nullable ? undef : $col_info->{default_value}; > } > $self->$col($val); > } >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index ed7ad7a3516..54595fecc67 100755 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -2675,10 +2675,10 @@ subtest 'lock' => sub { > }; > > subtest 'anonymize' => sub { >- plan tests => 10; >+ plan tests => 11; > >- my $patron1 = $builder->build_object( { class => 'Koha::Patrons' } ); >- my $patron2 = $builder->build_object( { class => 'Koha::Patrons' } ); >+ my $patron1 = $builder->build_object( { class => 'Koha::Patrons' } )->store; >+ my $patron2 = $builder->build_object( { class => 'Koha::Patrons' } )->store; > > # First try patron with issues > my $issue = $builder->build_object( >@@ -2696,16 +2696,17 @@ subtest 'anonymize' => sub { > is( $patron1->firstname, undef, 'First name cleared' ); > isnt( $patron1->surname, $surname, 'Surname changed' ); > ok( $patron1->surname =~ /^\w{10}$/, 'Mandatory surname randomized' ); >- is( $patron1->branchcode, $branchcode, 'Branch code skipped' ); >- is( $patron1->email, undef, 'Email was mandatory, must be cleared' ); >+ is( $patron1->branchcode, $branchcode, 'Branch code skipped' ); >+ is( $patron1->email, undef, 'Email was mandatory, must be cleared' ); >+ is( $patron1->checkprevcheckout, 'inherit', 'Enum checkprevcheckout is reset to the default value' ); > > # Test wrapper in Koha::Patrons >- $patron1->surname($surname)->store; # restore >+ $patron1->surname($surname)->store; # restore > my $rs = Koha::Patrons->search( { borrowernumber => [ $patron1->borrowernumber, $patron2->borrowernumber ] } ) > ->anonymize; >- $patron1->discard_changes; # refresh >+ $patron1->discard_changes; # refresh > isnt( $patron1->surname, $surname, 'Surname patron1 changed again' ); >- $patron2->discard_changes; # refresh >+ $patron2->discard_changes; # refresh > is( $patron2->firstname, undef, 'First name patron2 cleared' ); > }; > >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40337
:
183918
|
183919
|
183946
|
183947
|
183948
| 183969 |
183970