Bugzilla – Attachment 112905 Details for
Bug 26516
Importing records with unexpected format of copyrightdate fails
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26516: [alternate] Don't accept incorrect values for copyrightdate/publicationyear
Bug-26516-alternate-Dont-accept-incorrect-values-f.patch (text/plain), 2.83 KB, created by
David Nind
on 2020-11-03 10:27:26 UTC
(
hide
)
Description:
Bug 26516: [alternate] Don't accept incorrect values for copyrightdate/publicationyear
Filename:
MIME Type:
Creator:
David Nind
Created:
2020-11-03 10:27:26 UTC
Size:
2.83 KB
patch
obsolete
>From 88ae9767321a01ef51ff4f67cfb58f3079e5c3f9 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 23 Sep 2020 14:42:40 +0000 >Subject: [PATCH] Bug 26516: [alternate] Don't accept incorrect values for > copyrightdate/publicationyear > >The previous patch rejects incorrect values when saving to the db specifically for copyrightdate >An error is thrown for the int conversion when it fails > >Rather than catching things when saving we can fix the value when generated, simply returning null when parsing >the record > >To test: >1 - Add a new record to Koha making sure data is valid except 260$c: > 198- >2 - Save the record >3 - It fails >4 - Apply this patch >5 - Restart all the thigns >6 - Repeat >7 - Success! > >Signed-off-by: David Nind <david@davidnind.com> >--- > C4/Biblio.pm | 2 ++ > t/db_dependent/Biblio/TransformMarcToKoha.t | 8 +++++--- > 2 files changed, 7 insertions(+), 3 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 6b7e78e05b..0a8633f627 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -2468,6 +2468,8 @@ sub _adjust_pubyear { > /xms ) { # the form 198-? occurred in Dutch ISBD rules > my $digits = $+{year}; > $retval = $digits * ( 10 ** ( 4 - length($digits) )); >+ } else { >+ $retval = undef; > } > return $retval; > } >diff --git a/t/db_dependent/Biblio/TransformMarcToKoha.t b/t/db_dependent/Biblio/TransformMarcToKoha.t >index 8d1e94c1eb..60d7a95833 100755 >--- a/t/db_dependent/Biblio/TransformMarcToKoha.t >+++ b/t/db_dependent/Biblio/TransformMarcToKoha.t >@@ -94,7 +94,7 @@ subtest 'Multiple mappings for one kohafield' => sub { > }; > > subtest 'Testing _adjust_pubyear' => sub { >- plan tests => 10; >+ plan tests => 12; > > is( C4::Biblio::_adjust_pubyear('2004 c2000 2007'), 2000, 'First cYEAR' ); > is( C4::Biblio::_adjust_pubyear('2004 2000 2007'), 2004, 'First year' ); >@@ -103,9 +103,11 @@ subtest 'Testing _adjust_pubyear' => sub { > is( C4::Biblio::_adjust_pubyear('197X'), 1970, '197X on its own' ); > is( C4::Biblio::_adjust_pubyear('1...'), 1000, '1... on its own' ); > is( C4::Biblio::_adjust_pubyear('12?? 13xx'), 1200, '12?? first' ); >- is( C4::Biblio::_adjust_pubyear('12? 1x'), '12? 1x', 'Too short' ); >- is( C4::Biblio::_adjust_pubyear('198-'), '198-', 'Missing question mark' ); >+ is( C4::Biblio::_adjust_pubyear('12? 1x'), undef, 'Too short return nothing as data must be int' ); >+ is( C4::Biblio::_adjust_pubyear('198-'), undef, 'Missing question mark, nothing is returned as data must be int' ); > is( C4::Biblio::_adjust_pubyear('198-?'), '1980', '198-?' ); >+ is( C4::Biblio::_adjust_pubyear('1981-'), '1981', 'Date range returns first date' ); >+ is( C4::Biblio::_adjust_pubyear('broken'), undef, 'Non-matchign data returns nothing as the field must be int' ); > }; > > subtest 'Test repeatable subfields' => sub { >-- >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 26516
:
110602
|
110605
|
112905
|
113655