From ffdc309bfaad2b610bd1978c4735316d916721be Mon Sep 17 00:00:00 2001
From: Andrew Nugged <nugged@gmail.com>
Date: Sat, 16 Oct 2021 01:16:16 +0300
Subject: [PATCH] Bug 20447: (QA follow-up) Fix framework switching bug

Form's parameter never used because $record was always defined, with
new or with existing holding, but always.

Fixed by adding incoming $holding_id presence check.

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
---
 cataloguing/addholding.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cataloguing/addholding.pl b/cataloguing/addholding.pl
index 2eb509c95a..71bd3503d1 100755
--- a/cataloguing/addholding.pl
+++ b/cataloguing/addholding.pl
@@ -586,7 +586,7 @@ my ($template, $loggedinuser, $cookie) = get_template_and_user(
 
 my $record = $holding_id ? Koha::Holdings->find($holding_id) : Koha::Holding->new();
 
-$frameworkcode = $record->frameworkcode if ($record);
+$frameworkcode = $record->frameworkcode if $holding_id && $record;
 $frameworkcode = 'HLD' if not $frameworkcode or $frameworkcode eq '';
 
 # TODO: support in advanced editor?
-- 
2.30.2