View | Details | Raw Unified | Return to bug 37757
Collapse All | Expand All

(-)a/Koha/Patron.pm (-1 / +6 lines)
Lines 20-26 package Koha::Patron; Link Here
20
20
21
use Modern::Perl;
21
use Modern::Perl;
22
22
23
use List::MoreUtils qw( any uniq );
23
use List::MoreUtils qw( any none uniq );
24
use JSON qw( to_json );
24
use JSON qw( to_json );
25
use Unicode::Normalize qw( NFKD );
25
use Unicode::Normalize qw( NFKD );
26
use Try::Tiny;
26
use Try::Tiny;
Lines 1642-1647 sub notice_email_address { Link Here
1642
1642
1643
    my $which_address = C4::Context->preference("EmailFieldPrimary");
1643
    my $which_address = C4::Context->preference("EmailFieldPrimary");
1644
1644
1645
    if ( $which_address && ( none { $_ eq $which_address } qw{email emailpro B_email cardnumber MULTI} ) ) {
1646
        warn "Invalid value for EmailFieldPrimary ($which_address)";
1647
        $which_address = undef;
1648
    }
1649
1645
    # if syspref is set to 'first valid', look up email address
1650
    # if syspref is set to 'first valid', look up email address
1646
    return $self->first_valid_email_address
1651
    return $self->first_valid_email_address
1647
        unless $which_address;
1652
        unless $which_address;
(-)a/t/db_dependent/Koha/Patron.t (-2 / +16 lines)
Lines 1791-1797 subtest 'notify_library_of_registration()' => sub { Link Here
1791
1791
1792
subtest 'notice_email_address() tests' => sub {
1792
subtest 'notice_email_address() tests' => sub {
1793
1793
1794
    plan tests => 3;
1794
    plan tests => 5;
1795
1795
1796
    $schema->storage->txn_begin;
1796
    $schema->storage->txn_begin;
1797
1797
Lines 1817-1822 subtest 'notice_email_address() tests' => sub { Link Here
1817
        "Koha::Patron->notice_email_address returns correct value when EmailFieldPrimary is 'MULTI' and EmailFieldSelection is 'email,emailpro'"
1817
        "Koha::Patron->notice_email_address returns correct value when EmailFieldPrimary is 'MULTI' and EmailFieldSelection is 'email,emailpro'"
1818
    );
1818
    );
1819
1819
1820
    my $invalid = 'potato';
1821
1822
    t::lib::Mocks::mock_preference( 'EmailFieldPrecedence', 'email|emailpro' );
1823
    t::lib::Mocks::mock_preference( 'EmailFieldPrimary',    $invalid );
1824
1825
    my $email;
1826
    warning_is { $email = $patron->notice_email_address(); }
1827
    qq{Invalid value for EmailFieldPrimary ($invalid)},
1828
        'Warning correctly generated on invalid system preference';
1829
1830
    is(
1831
        $email, $patron->email,
1832
        "Koha::Patron->notice_email_address falls back to correct value when EmailFieldPrimary is invalid"
1833
    );
1834
1820
    $schema->storage->txn_rollback;
1835
    $schema->storage->txn_rollback;
1821
};
1836
};
1822
1837
1823
- 

Return to bug 37757