Bug 30250: Use ApplyFrameworkDefaults when cataloguing
[srvgit] / cataloguing / additem.pl
index bdd2061..c722f60 100755 (executable)
@@ -47,6 +47,7 @@ use Storable qw( freeze thaw );
 use URI::Escape qw( uri_escape_utf8 );
 use C4::Members;
 use Koha::UI::Form::Builder::Item;
+use Koha::Result::Boolean;
 
 use MARC::File::XML;
 use URI::Escape qw( uri_escape_utf8 );
@@ -412,7 +413,12 @@ if ($op eq "additem") {
 #-------------------------------------------------------------------------------
     # check that there is no issue on this item before deletion.
     my $item = Koha::Items->find($itemnumber);
-    my $deleted = $item->safe_delete;
+    my $deleted;
+    if( $item ) {
+        $deleted = $item->safe_delete;
+    } else {
+        $deleted = Koha::Result::Boolean->new(0)->add_message({ message => 'item_not_found' });
+    }
     if ( $deleted ) {
         print $input->redirect("additem.pl?biblionumber=$biblionumber&frameworkcode=$frameworkcode&searchid=$searchid");
         exit;
@@ -607,8 +613,6 @@ my $branchcode = $input->param('branch') || C4::Context->userenv->{branch};
 my @subfields_to_prefill;
 if ( $nextop eq 'additem' && $op ne 'dupeitem' && $prefillitem ) {
     @subfields_to_prefill = split(' ', C4::Context->preference('SubfieldsToUseWhenPrefill'));
-    # Setting to 1 element if SubfieldsToUseWhenPrefill is empty to prevent all the subfields to be prefilled
-    @subfields_to_prefill = ("") unless @subfields_to_prefill;
 }
 
 # Getting list of subfields to keep when restricted editing is enabled