From 3c1be2436c3217dc938b02e08a02b534efa76b89 Mon Sep 17 00:00:00 2001
From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Date: Mon, 10 Feb 2014 13:28:16 +0100
Subject: [PATCH] [SIGNED OFF] Bug 11732: Eliminate warning on undefined
 branchcode

When you run the Reserves test, you have the warnings:
Use of uninitialized value $branchcode in hash element at /usr/share/koha/testclone/C4/Letters.pm line 138.
Use of uninitialized value $branchcode in hash element at /usr/share/koha/testclone/C4/Letters.pm line 148.
This patch removes that warning.

Test plan:
Run the Reserves.t again.

Revised Test Plan
-----------------
Run the following on the command line prompt before and after
applying the patch:
    perl -e "use C4::Letters; *C4::Context::userenv= sub { return {} }; my \$blah=C4::Letters::getletter('circulation','DUE', 'BRA');"
Before the patch there will be errors (as above), after there will not.

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
---
 C4/Letters.pm |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/C4/Letters.pm b/C4/Letters.pm
index 2595369..6709294 100644
--- a/C4/Letters.pm
+++ b/C4/Letters.pm
@@ -126,7 +126,6 @@ our %letter;
 sub getletter {
     my ( $module, $code, $branchcode ) = @_;
 
-    $branchcode ||= '';
 
     if ( C4::Context->preference('IndependentBranches')
             and $branchcode
@@ -134,6 +133,7 @@ sub getletter {
 
         $branchcode = C4::Context->userenv->{'branch'};
     }
+    $branchcode //= '';
 
     if ( my $l = $letter{$module}{$code}{$branchcode} ) {
         return { %$l }; # deep copy
-- 
1.7.9.5