From e2e254b1ff7f6aee4e7419a6dac03c4a0e8083dd Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Date: Mon, 4 Nov 2019 12:25:33 +0100
Subject: [PATCH] Bug 23933: (bug 10132 follow-up) Fix commit_file.pl

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
---
 C4/AuthoritiesMarc.pm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm
index 0d90b37d67..c0c42df2bd 100644
--- a/C4/AuthoritiesMarc.pm
+++ b/C4/AuthoritiesMarc.pm
@@ -575,7 +575,8 @@ sub AddAuthority {
         my $marcorgcode = C4::Context->preference('MARCOrgCode');
         if ( $userenv && $userenv->{'branch'} ) {
             $library = Koha::Libraries->find( $userenv->{'branch'} );
-            $marcorgcode = $library->get_effective_marcorgcode;
+            # userenv's library could not exist because of a trick in misc/commit_file.pl (see FIXME and set_userenv statement)
+            $marcorgcode = $library ? $library->get_effective_marcorgcode : $marcorgcode;
         }
 		if (!$record->leader) {
 			$record->leader($leader);
-- 
2.20.1