From f1b1e362b731e525b760a9aa500b1bf6c80cf0fc Mon Sep 17 00:00:00 2001 From: Petro Vashchuk Date: Sun, 24 Jan 2021 22:08:05 +0200 Subject: [PATCH] Bug 27539: fix console warnings "Use of uninitialized value in split" When items in the database have NULLs for some fields, those are SELECTed as undefs and those values arrive as strings to be splitted by "split" command, and that produces undef warnings. That is expected behaviour to not have data for those fields sometimes, so we just need to add perl's "defaulting" to empty strings for split. To reproduce: 1) Place a hold on an item that has an available call number, copy numbers or enumeration empty. 2) Head to the Holds to Pull page and check the console to see "Use of uninitialized value in split" errors. 3) Apply the patch. 4) Refresh the Holds to Pull page and check the console again to ensure that new errors about "Use of uninitialized value in split" weren't added. --- circ/pendingreserves.pl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/circ/pendingreserves.pl b/circ/pendingreserves.pl index 01cf877b55..122ed9a48d 100755 --- a/circ/pendingreserves.pl +++ b/circ/pendingreserves.pl @@ -263,17 +263,17 @@ while ( my $data = $sth->fetchrow_hashref ) { author => $data->{author}, borrowernumber => $data->{borrowernumber}, biblionumber => $data->{biblionumber}, - holdingbranches => [split('\|', $data->{l_holdingbranch})], + holdingbranches => [split('\|', $data->{l_holdingbranch} // '')], branch => $data->{l_branch}, - itemcallnumber => [split('\|', $data->{l_itemcallnumber})], - enumchron => [split('\|', $data->{l_enumchron})], - copyno => [split('\|', $data->{l_copynumber})], - barcode => [split('\|', $data->{l_barcode})], + itemcallnumber => [split('\|', $data->{l_itemcallnumber} // '')], + enumchron => [split('\|', $data->{l_enumchron} // '')], + copyno => [split('\|', $data->{l_copynumber} // '')], + barcode => [split('\|', $data->{l_barcode} // '')], count => $data->{icount}, rcount => $data->{rcount}, pullcount => $data->{icount} <= $data->{rcount} ? $data->{icount} : $data->{rcount}, - itemTypes => [split('\|', $data->{l_item_type})], - locations => [split('\|', $data->{l_location})], + itemTypes => [split('\|', $data->{l_item_type} // '')], + locations => [split('\|', $data->{l_location} // '')], reserve_id => $data->{reserve_id}, holdingbranch => $data->{holdingbranch}, homebranch => $data->{homebranch}, -- 2.28.0