Bugzilla – Attachment 171162 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: Make notice_email_address() handle EmailFieldPrimary values more robustly
Bug-37757-Make-noticeemailaddress-handle-EmailFiel.patch (text/plain), 2.69 KB, created by
David Nind
on 2024-09-06 23:17:13 UTC
(
hide
)
Description:
Bug 37757: Make notice_email_address() handle EmailFieldPrimary values more robustly
Filename:
MIME Type:
Creator:
David Nind
Created:
2024-09-06 23:17:13 UTC
Size:
2.69 KB
patch
obsolete
>From 8f389f3053af050835d573f75f762bda2f6d945a Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 28 Aug 2024 15:01:37 -0300 >Subject: [PATCH] Bug 37757: Make notice_email_address() handle > EmailFieldPrimary values more robustly > >This patchset makes: > >* The EmailFieldPrimary value 'OFF' be replaced by an empty string >* Koha::Patron->notice_email_address() handle the empty case more > gracefully > >To test: >1. On main, manually set the EmailFieldPrimary syspref to empty > $ ktd --shell > k$ koha-mysql kohadev > > UPDATE systempreferences SET value='' WHERE variable='EmailFieldPrimary'; >2. Enable `AutoEmailNewUser` >3. Create a new user >=> FAIL: Koha explodes like: >``` >The method Koha::Patron-> is not covered by tests! > >Trace begun at /kohadevbox/koha/Koha/Object.pm line 992 >Koha::Object::AUTOLOAD('Koha::Patron=HASH(0xaaaae37ac550)') called at /kohadevbox/koha/Koha/Patron.pm line 1662 >Koha::Patron::notice_email_address('Koha::Patron=HASH(0xaaaae37ac550)') called at /kohadevbox/koha/members/memberentry.pl line 448 >... > >4. Apply this patches >5. Run: > k$ updatedatabase >=> SUCCESS: Update succeeds >6. Restart all and retry creating a patron >=> SUCCESS: It worked! >7. Sign off :-D > >Signed-off-by: David Nind <david@davidnind.com> >--- > Koha/Patron.pm | 16 +++++++--------- > 1 file changed, 7 insertions(+), 9 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 3e4e89c799..dde7d73d1a 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -1630,22 +1630,21 @@ sub return_claims { > > =head3 notice_email_address > >- my $email = $patron->notice_email_address; >+ my $email = $patron->notice_email_address; > > Return the email address of patron used for notices. > Returns the empty string if no email address. > > =cut > >-sub notice_email_address{ >- my ( $self ) = @_; >+sub notice_email_address { >+ my ($self) = @_; > > my $which_address = C4::Context->preference("EmailFieldPrimary"); > >- # if syspref is set to 'first valid' (value == OFF), look up email address >- if ( $which_address eq 'OFF' ) { >- return $self->first_valid_email_address; >- } >+ # if syspref is set to 'first valid', look up email address >+ return $self->first_valid_email_address >+ unless $which_address; > > # if syspref is set to 'selected addresses' (value == MULTI), look up email addresses > if ( $which_address eq 'MULTI' ) { >@@ -1655,11 +1654,10 @@ sub notice_email_address{ > my $email_address = $self->$email_field; > push @addresses, $email_address if $email_address; > } >- return join(",",@addresses); >+ return join( ",", @addresses ); > } > > return $self->$which_address || ''; >- > } > > =head3 first_valid_email_address >-- >2.39.2
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