Bug 19350 - Holds without link in 773 trigger SQL::Abstract::puke
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 20 Sep 2017 14:01:16 +0000 (16:01 +0200)
committerMason James <mtj@kohaaloha.com>
Tue, 24 Oct 2017 04:35:22 +0000 (17:35 +1300)
Test:
1. find bibio without items which has something in field 773
   (for us, it's article) but doesn't have 0 or 9 (host item entry)
2. click on hold in left menu
3. verify application error
4. apply patch and verify that it works

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Mason James <mtj@kohaaloha.com>

C4/Items.pm

index 0f0465e..e2ddff8 100644 (file)
@@ -1667,7 +1667,14 @@ sub get_hostitemnumbers_of {
 
     foreach my $hostfield ( $marcrecord->field($tag) ) {
         my $hostbiblionumber = $hostfield->subfield($biblio_s);
+        next unless $hostbiblionumber; # have tag, don't have $biblio_s subfield
         my $linkeditemnumber = $hostfield->subfield($item_s);
+
+        if ( ! $linkeditemnumber ) {
+            warn "ERROR biblionumber $biblionumber has 773^0, but doesn't have 9";
+            next;
+        }
+
         my @itemnumbers;
         if (my $itemnumbers = get_itemnumbers_of($hostbiblionumber)->{$hostbiblionumber})
         {