Bug 16191: t/Ris.t is noisy
authorMark Tompsett <mtompset@hotmail.com>
Fri, 1 Apr 2016 21:59:29 +0000 (17:59 -0400)
committerFrédéric Demians <f.demians@tamil.fr>
Wed, 27 Apr 2016 14:41:40 +0000 (16:41 +0200)
TEST PLAN
---------
1) prove t/Ris.t
   -- very noisy
2) apply patch
3) prove t/Ris.t
   -- just one confusing noise.
4) run koha qa test tools

Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Brendan Gallagher brendan@bywatersolutions.com
(cherry picked from commit 5b909a82693d452d233e95d7598092aa5ee14c17)
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
(cherry picked from commit af42fd5e81c7ce2764dc9796293e9815f9809b54)
Signed-off-by: Frédéric Demians <f.demians@tamil.fr>

C4/Ris.pm

index fa1ef29..04af471 100644 (file)
--- a/C4/Ris.pm
+++ b/C4/Ris.pm
@@ -342,7 +342,8 @@ sub print_typetag {
                );
     
     ## The type of a MARC record is found at position 06 of the leader
-    my $typeofrecord = substr($leader, 6, 1);
+    my $typeofrecord = defined($leader) && length $leader >=6 ?
+                       substr($leader, 6, 1): undef;
 
     ## ToDo: for books, field 008 positions 24-27 might have a few more
     ## hints
@@ -350,7 +351,11 @@ sub print_typetag {
     my %typehash;
     
     ## the ukmarc here is just a guess
-    if ($intype eq "marc21" || $intype eq "ukmarc") {
+    if (! defined $intype) {
+        ## assume MARC21 as default
+        %typehash = %ustypehash;
+    }
+    elsif ($intype eq "marc21" || $intype eq "ukmarc") {
        %typehash = %ustypehash;
     }
     elsif ($intype eq "unimarc") {
@@ -361,7 +366,7 @@ sub print_typetag {
        %typehash = %ustypehash;
     }
 
-    if (!exists $typehash{$typeofrecord}) {
+    if (!defined $typeofrecord || !exists $typehash{$typeofrecord}) {
        print "TY  - BOOK\r\n"; ## most reasonable default
        warn ("no type found - assume BOOK") if $marcprint;
     }