Bugzilla – Attachment 120786 Details for
Bug 28220
Exception not caught when importing patrons
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28220: Handle InvalidType
Bug-28220-Handle-InvalidType.patch (text/plain), 3.05 KB, created by
Nick Clemens (kidclamp)
on 2021-05-10 13:28:09 UTC
(
hide
)
Description:
Bug 28220: Handle InvalidType
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2021-05-10 13:28:09 UTC
Size:
3.05 KB
patch
obsolete
>From c1ed26dbcb42723b08cd0296b9333e942e131878 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 6 May 2021 10:46:24 +0200 >Subject: [PATCH] Bug 28220: Handle InvalidType > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > Koha/Patrons/Import.pm | 4 +++- > t/db_dependent/Koha/Patrons/Import.t | 21 +++++++++++++++++++-- > 2 files changed, 22 insertions(+), 3 deletions(-) > >diff --git a/Koha/Patrons/Import.pm b/Koha/Patrons/Import.pm >index 13597c3423..e3880eda44 100644 >--- a/Koha/Patrons/Import.pm >+++ b/Koha/Patrons/Import.pm >@@ -397,9 +397,11 @@ sub import_patrons { > }); > } catch { > $invalid++; >+ my $patron_id = defined $matchpoint ? $borrower{$matchpoint} : $matchpoint_attr_type; > if ( $_->isa('Koha::Exceptions::Patron::Attribute::UniqueIDConstraint') ) { >- my $patron_id = defined $matchpoint ? $borrower{$matchpoint} : $matchpoint_attr_type; > push @errors, { patron_attribute_unique_id_constraint => 1, patron_id => $patron_id, attribute => $_->attribute }; >+ } elsif ( $_->isa('Koha::Exceptions::Patron::Attribute::InvalidType') ) { >+ push @errors, { patron_attribute_invalid_type => 1, patron_id => $patron_id, attribute_type_code => $_->type }; > } else { > push @errors, { unknown_error => 1 }; > } >diff --git a/t/db_dependent/Koha/Patrons/Import.t b/t/db_dependent/Koha/Patrons/Import.t >index b343b60f86..edc9544944 100755 >--- a/t/db_dependent/Koha/Patrons/Import.t >+++ b/t/db_dependent/Koha/Patrons/Import.t >@@ -845,7 +845,7 @@ subtest 'test_format_dates' => sub { > > subtest 'patron_attributes' => sub { > >- plan tests => 6; >+ plan tests => 10; > > t::lib::Mocks::mock_preference('ExtendedPatronAttributes', 1); > >@@ -906,7 +906,7 @@ subtest 'patron_attributes' => sub { > $patron->delete; > } > >- { >+ { # UniqueIDConstraint > $builder->build_object( > { > class => 'Koha::Patron::Attributes', >@@ -927,6 +927,23 @@ subtest 'patron_attributes' => sub { > is( $error->{attribute}->code, $unique_attribute_type->code ); > > my $patron = Koha::Patrons->find({cardnumber => $cardnumber}); >+ is( $patron, undef, 'Patron is not created' ); >+ } >+ >+ { #InvalidType >+ my $attributes = { >+ $non_existent_attribute_type_code => ['my non-existent attribute'], >+ $normal_attribute_type->code => ['my attribute 1'], >+ }; >+ my $fh = build_csv({ %$attributes }); >+ >+ my $result = $patrons_import->import_patrons({file => $fh, matchpoint => 'cardnumber'}); >+ my $error = $result->{errors}->[0]; >+ is( $error->{patron_attribute_invalid_type}, 1 ); >+ is( $error->{patron_id}, $cardnumber ); >+ is( $error->{attribute_type_code}, $non_existent_attribute_type_code ); >+ >+ my $patron = Koha::Patrons->find({cardnumber => $cardnumber}); > is( $patron, undef ); > > } >-- >2.11.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 28220
:
120549
|
120607
|
120608
|
120609
|
120610
|
120611
|
120612
|
120613
|
120614
|
120783
|
120784
|
120785
|
120786
|
120787
|
120788
|
120789
|
120790
|
120885
|
120886
|
120887
|
120888
|
120889
|
120890
|
120891
|
120892