From d4f06e50237ede04f79650955e4cbb811e3acf9d Mon Sep 17 00:00:00 2001 From: Matthias Meusburger Date: Fri, 25 Sep 2009 15:30:12 +0200 Subject: [PATCH] MT 1094, Following : added a test to check if we really found the item --- C4/Items.pm | 27 ++++++++++++++++++--------- cataloguing/moveitem.pl | 3 +-- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index 0e7bc9ca76..a060c36ae9 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -2025,6 +2025,7 @@ MoveItemFromBiblio($itenumber, $frombiblio, $tobiblio); Moves an item from a biblio to another +Returns undef if the move failed or the biblionumber of the destination record otherwise =cut sub MoveItemFromBiblio { my ($itemnumber, $frombiblio, $tobiblio) = @_; @@ -2055,19 +2056,27 @@ sub MoveItemFromBiblio { $record->delete_field($fielditem) } } - # Saving the modification - ModBiblioMarc($record, $frombiblio, $frameworkcode); - # Getting the record we want to move the item to - $record = GetMarcBiblio($tobiblio); + # If we found an item (should always true, except in case of database-marcxml inconsistency) + if ($item) { - # Inserting the previously saved item - $record->insert_fields_ordered($item); + # Saving the modification + ModBiblioMarc($record, $frombiblio, $frameworkcode); - # Saving the modification - ModBiblioMarc($record, $tobiblio, $frameworkcode); + # Getting the record we want to move the item to + $record = GetMarcBiblio($tobiblio); + + # Inserting the previously saved item + $record->insert_fields_ordered($item); + + # Saving the modification + ModBiblioMarc($record, $tobiblio, $frameworkcode); + + } else { + return undef; + } } else { - return -1; + return undef; } } diff --git a/cataloguing/moveitem.pl b/cataloguing/moveitem.pl index 2aecfffdab..0186435cc1 100755 --- a/cataloguing/moveitem.pl +++ b/cataloguing/moveitem.pl @@ -70,10 +70,9 @@ if ($barcode && $biblionumber) { if ($item) { my $results = GetBiblioFromItemNumber($itemnumber, $barcode); - my $frombiblionumber = $results->{'biblionumber'}; + my $frombiblionumber = $results->{'biblionumber'}; my $moveresult = MoveItemFromBiblio($itemnumber, $frombiblionumber, $biblionumber); - if ($moveresult) { $template->param(success => 1); } else { -- 2.39.5