From 53f852627eedab219a767de40e7139901b82ca03 Mon Sep 17 00:00:00 2001 From: erickson Date: Thu, 28 Aug 2008 18:34:43 +0000 Subject: [PATCH] repaired record auto-delete code which could leave un-deleted volumes attached to a deleted copy if the volumes had no copies git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_2@10471 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/Application/Cat.pm | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm b/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm index a41dd4b21d..425f42753e 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm @@ -876,19 +876,24 @@ sub merge_holds { # --------------------------------------------------------------------------- +# returns true if the given title (id) has no un-deleted volumes or +# copies attached. If a context volume is defined, a record +# is considered empty only if the context volume is the only +# remaining volume on the record. # --------------------------------------------------------------------------- - -# returns true if the given title (id) has no un-deleted -# copies attached sub title_is_empty { - my( $editor, $rid ) = @_; + my( $editor, $rid, $vol_id ) = @_; return 0 if $rid == OILS_PRECAT_RECORD; my $cnlist = $editor->search_asset_call_number( { record => $rid, deleted => 'f' }, { idlist => 1 } ); - return 1 unless @$cnlist; + return 1 unless @$cnlist; # no attached volumes + return 0 if @$cnlist > 1; # multiple attached volumes + return 0 unless $$cnlist[0] == $vol_id; # attached volume is not the context vol. + + # see if the sole remaining context volume has any attached copies for my $cn (@$cnlist) { my $copylist = $editor->search_asset_copy( [ @@ -1105,7 +1110,7 @@ sub remove_empty_objects { my $aoe = $U->ou_ancestor_setting_value( $editor->requestor->ws_ou, 'cat.bib.alert_on_empty', $editor); - if( title_is_empty($editor, $vol->record) ) { + if( title_is_empty($editor, $vol->record, $vol->id) ) { # delete this volume if it's not already marked as deleted unless( $U->is_true($vol->deleted) || $vol->isdeleted ) { -- 2.11.0