Bugzilla – Attachment 171450 Details for
Bug 37757
notice_email_address explodes if EmailFieldPrimary is not valid
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37757: (follow-up) Warn on bad values and survive
Bug-37757-follow-up-Warn-on-bad-values-and-survive.patch (text/plain), 2.49 KB, created by
Martin Renvoize (ashimema)
on 2024-09-13 11:53:43 UTC
(
hide
)
Description:
Bug 37757: (follow-up) Warn on bad values and survive
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-09-13 11:53:43 UTC
Size:
2.49 KB
patch
obsolete
>From 805ce54cd6cf9db7a3dd06628281246ad099b3c4 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 28 Aug 2024 15:43:53 -0300 >Subject: [PATCH] Bug 37757: (follow-up) Warn on bad values and survive > >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Patron.pm | 7 ++++++- > t/db_dependent/Koha/Patron.t | 17 ++++++++++++++++- > 2 files changed, 22 insertions(+), 2 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index dde7d73d1a1..8058acd5dce 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -20,7 +20,7 @@ package Koha::Patron; > > use Modern::Perl; > >-use List::MoreUtils qw( any uniq ); >+use List::MoreUtils qw( any none uniq ); > use JSON qw( to_json ); > use Unicode::Normalize qw( NFKD ); > use Try::Tiny; >@@ -1642,6 +1642,11 @@ sub notice_email_address { > > my $which_address = C4::Context->preference("EmailFieldPrimary"); > >+ if ( $which_address && ( none { $_ eq $which_address } qw{email emailpro B_email cardnumber MULTI} ) ) { >+ warn "Invalid value for EmailFieldPrimary ($which_address)"; >+ $which_address = undef; >+ } >+ > # if syspref is set to 'first valid', look up email address > return $self->first_valid_email_address > unless $which_address; >diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t >index fec2bb5ef2c..970235ecc55 100755 >--- a/t/db_dependent/Koha/Patron.t >+++ b/t/db_dependent/Koha/Patron.t >@@ -1791,7 +1791,7 @@ subtest 'notify_library_of_registration()' => sub { > > subtest 'notice_email_address() tests' => sub { > >- plan tests => 3; >+ plan tests => 5; > > $schema->storage->txn_begin; > >@@ -1817,6 +1817,21 @@ subtest 'notice_email_address() tests' => sub { > "Koha::Patron->notice_email_address returns correct value when EmailFieldPrimary is 'MULTI' and EmailFieldSelection is 'email,emailpro'" > ); > >+ my $invalid = 'potato'; >+ >+ t::lib::Mocks::mock_preference( 'EmailFieldPrecedence', 'email|emailpro' ); >+ t::lib::Mocks::mock_preference( 'EmailFieldPrimary', $invalid ); >+ >+ my $email; >+ warning_is { $email = $patron->notice_email_address(); } >+ qq{Invalid value for EmailFieldPrimary ($invalid)}, >+ 'Warning correctly generated on invalid system preference'; >+ >+ is( >+ $email, $patron->email, >+ "Koha::Patron->notice_email_address falls back to correct value when EmailFieldPrimary is invalid" >+ ); >+ > $schema->storage->txn_rollback; > }; > >-- >2.46.0
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 37757
:
170840
|
170841
|
170842
|
170843
|
171160
|
171161
|
171162
|
171163
|
171447
|
171448
|
171449
| 171450 |
171496