From 89fc5dfeb2a7b1a39f433fd7d781360a0baae39a Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 14 Sep 2017 12:23:09 +0000 Subject: [PATCH] [SIGNED-OFF] Bug 19315: [16.11.x] Use bibnum instead of biblionumber in routing-preview.pl and add item check To test: 1 - Create a serial subscription attached to a record 2 - Receive some issues 3 - Edit the subscription 4 - Go to serails collection 5 - Try to print a routing list 6 - You may or may not get the right serial 7 - Additionally create a subscription attached to a bib with no items 8 - Try to print a routing list for this serial 9 - You will get 'Internal server error' 10 - Apply patch 11 - Print routing list for first serial 12 - You will always get the correct bib 13 - Print routing list for second serial 14 - You should no longer get an error Signed-off-by: Caroline Cyr La Rose Signed-off-by: Marcel de Rooy Signed-off-by: Katrin Fischer --- serials/routing-preview.pl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/serials/routing-preview.pl b/serials/routing-preview.pl index 9c4238f..64c7752 100755 --- a/serials/routing-preview.pl +++ b/serials/routing-preview.pl @@ -62,15 +62,15 @@ my ($template, $loggedinuser, $cookie); if($ok){ # get biblio information.... - my $biblio = $subs->{'biblionumber'}; - my ($count2,@bibitems) = GetBiblioItemByBiblioNumber($biblio); - my @itemresults = GetItemsInfo( $subs->{biblionumber} ); - my $branch = $itemresults[0]->{'holdingbranch'}; + my $biblionumber = $subs->{'bibnum'}; + my ($count2,@bibitems) = GetBiblioItemByBiblioNumber($biblionumber); + my @itemresults = GetItemsInfo( $biblionumber ); + my $branch = scalar @itemresults ? $itemresults[0]->{'holdingbranch'} : $subs->{branchcode}; my $branchname = Koha::Libraries->find($branch)->branchname; if (C4::Context->preference('RoutingListAddReserves')){ # get existing reserves ..... - my $reserves = GetReservesFromBiblionumber({ biblionumber => $biblio }); + my $reserves = GetReservesFromBiblionumber({ biblionumber => $biblionumber }); my $count = scalar( @$reserves ); my $totalcount = $count; foreach my $res (@$reserves) { @@ -82,18 +82,18 @@ if($ok){ my $title = $subs->{'bibliotitle'}; for my $routing ( @routinglist ) { my $sth = $dbh->prepare('SELECT * FROM reserves WHERE biblionumber = ? AND borrowernumber = ? LIMIT 1'); - $sth->execute($biblio,$routing->{borrowernumber}); + $sth->execute($biblionumber,$routing->{borrowernumber}); my $reserve = $sth->fetchrow_hashref; if($routing->{borrowernumber} == $reserve->{borrowernumber}){ ModReserve({ rank => $routing->{ranking}, - biblionumber => $biblio, + biblionumber => $biblionumber, borrowernumber => $routing->{borrowernumber}, branchcode => $branch }); } else { - AddReserve($branch,$routing->{borrowernumber},$biblio,\@bibitems,$routing->{ranking}, undef, undef, $notes,$title); + AddReserve($branch,$routing->{borrowernumber},$biblionumber,\@bibitems,$routing->{ranking}, undef, undef, $notes,$title); } } } -- 2.1.4