From 281c1e2454fb3698a69bbbb93e77f02bbf3b36b4 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Fri, 28 Dec 2007 10:25:43 -0600 Subject: [PATCH] only munge copyrightdate and publicationyear if they exist Prior to this fix, those two keys were always created by TransformMarcToKoha even when not appropriate (e.g., for items). Signed-off-by: Joshua Ferraro --- C4/Biblio.pm | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 6e440e5d4e..1b9c02f298 100755 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -2770,26 +2770,31 @@ sub TransformMarcToKoha { } # modify copyrightdate to keep only the 1st year found - my $temp = $result->{'copyrightdate'}; - $temp =~ m/c(\d\d\d\d)/; # search cYYYY first - if ( $1 > 0 ) { - $result->{'copyrightdate'} = $1; - } - else { # if no cYYYY, get the 1st date. - $temp =~ m/(\d\d\d\d)/; - $result->{'copyrightdate'} = $1; + if (exists $result->{'copyrightdate'}) { + my $temp = $result->{'copyrightdate'}; + $temp =~ m/c(\d\d\d\d)/; # search cYYYY first + if ( $1 > 0 ) { + $result->{'copyrightdate'} = $1; + } + else { # if no cYYYY, get the 1st date. + $temp =~ m/(\d\d\d\d)/; + $result->{'copyrightdate'} = $1; + } } # modify publicationyear to keep only the 1st year found - $temp = $result->{'publicationyear'}; - $temp =~ m/c(\d\d\d\d)/; # search cYYYY first - if ( $1 > 0 ) { - $result->{'publicationyear'} = $1; - } - else { # if no cYYYY, get the 1st date. - $temp =~ m/(\d\d\d\d)/; - $result->{'publicationyear'} = $1; + if (exists $result->{'publicationyear'}) { + my $temp = $result->{'publicationyear'}; + $temp =~ m/c(\d\d\d\d)/; # search cYYYY first + if ( $1 > 0 ) { + $result->{'publicationyear'} = $1; + } + else { # if no cYYYY, get the 1st date. + $temp =~ m/(\d\d\d\d)/; + $result->{'publicationyear'} = $1; + } } + return $result; } -- 2.39.5