Bug 8015: (follow-up) don't require userenv
authorGalen Charlton <gmc@esilibrary.com>
Thu, 31 Oct 2013 22:36:39 +0000 (22:36 +0000)
committerGalen Charlton <gmc@esilibrary.com>
Thu, 31 Oct 2013 22:51:13 +0000 (22:51 +0000)
Core routines probably should never assume that they're
running with a valid userenv defined.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
C4/MarcModificationTemplates.pm

index f504621..50b77df 100644 (file)
@@ -495,7 +495,8 @@ sub ModifyRecordWithTemplate {
     warn( "Unmodified Record:\n" . $record->as_formatted() ) if DEBUG >= 10;
 
     my $current_date = DateTime->now()->ymd();
-    my $branchcode = C4::Context->userenv->{branch};
+    my $branchcode = '';
+    $branchcode = C4::Context->userenv->{branch} if C4::Context->userenv;
 
     my @actions = GetModificationTemplateActions( $template_id );