From: Thomas Berezansky Date: Mon, 30 Jan 2012 18:34:53 +0000 (-0500) Subject: Stop targeter crash on empty metarecord with holds X-Git-Tag: sprint4-merge-nov22~4585 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f27de9486a348bd828d28093640a0da8eee708b8;p=working%2FEvergreen.git Stop targeter crash on empty metarecord with holds By checking for 1 or more records before looking them up. Signed-off-by: Thomas Berezansky Signed-off-by: Ben Shum Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm index 2beaae5028..f6a4515a2d 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm @@ -1151,30 +1151,33 @@ sub new_hold_copy_targeter { # find all the potential copies if ($hold->hold_type eq 'M') { - for my $r ( map - {$_->record} - metabib::record_descriptor - ->search( - record => [ - map { - isTrue($_->deleted) ? () : ($_->id) - } metabib::metarecord->retrieve($hold->target)->source_records - ], - ( $types ? (item_type => [split '', $types]) : () ), - ( $formats ? (item_form => [split '', $formats]) : () ), - ( $lang ? (item_lang => $lang) : () ), - ) - ) { - my ($rtree) = $self - ->method_lookup( 'open-ils.storage.biblio.record_entry.ranged_tree') - ->run( $r->id, $hold->selection_ou, $hold->selection_depth ); - - for my $cn ( @{ $rtree->call_numbers } ) { - push @$all_copies, - asset::copy->search_where( - { id => [map {$_->id} @{ $cn->copies }], - deleted => 'f' } - ) if ($cn && @{ $cn->copies }); + my $records = [ + map { + isTrue($_->deleted) ? () : ($_->id) + } metabib::metarecord->retrieve($hold->target)->source_records + ]; + if(@$records > 0) { + for my $r ( map + {$_->record} + metabib::record_descriptor + ->search( + record => $records, + ( $types ? (item_type => [split '', $types]) : () ), + ( $formats ? (item_form => [split '', $formats]) : () ), + ( $lang ? (item_lang => $lang) : () ), + ) + ) { + my ($rtree) = $self + ->method_lookup( 'open-ils.storage.biblio.record_entry.ranged_tree') + ->run( $r->id, $hold->selection_ou, $hold->selection_depth ); + + for my $cn ( @{ $rtree->call_numbers } ) { + push @$all_copies, + asset::copy->search_where( + { id => [map {$_->id} @{ $cn->copies }], + deleted => 'f' } + ) if ($cn && @{ $cn->copies }); + } } } } elsif ($hold->hold_type eq 'T') {