From 27bbbda6e7147be2850bf1d544f3fcecfa2c7c71 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 5 Feb 2026 08:10:41 +0000 Subject: [PATCH] Bug 35612: (QA follow-up) Fix uninitialized value warnings When LostChargesControl system preference is not set (undefined), the code was generating 'Use of uninitialized value' warnings when comparing $lost_control_pref in string equality checks. This adds defined checks before the comparisons to handle the case where the preference is undefined, treating it the same as 'ItemHomeLibrary' (the default). Test plan: 1. Run prove t/db_dependent/Circulation.t 2. Verify all tests pass without warnings --- C4/Accounts.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/C4/Accounts.pm b/C4/Accounts.pm index cece86c7c41..b9c19a4adc7 100644 --- a/C4/Accounts.pm +++ b/C4/Accounts.pm @@ -82,11 +82,11 @@ sub chargelostitem { my $lost_control_pref = C4::Context->preference('LostChargesControl'); my $lost_control_branch; - if ( $lost_control_pref eq 'PatronLibrary' ) { + if ( defined $lost_control_pref && $lost_control_pref eq 'PatronLibrary' ) { $lost_control_branch = $patron->branchcode; - } elsif ( $lost_control_pref eq 'PickupLibrary' ) { + } elsif ( defined $lost_control_pref && $lost_control_pref eq 'PickupLibrary' ) { $lost_control_branch = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; - } else { # $lost_control_pref eq 'ItemHomeLibrary' + } else { # $lost_control_pref eq 'ItemHomeLibrary' or undefined $lost_control_branch = ( C4::Context->preference('HomeOrHoldingBranch') eq 'homebranch' ) ? $item->homebranch -- 2.52.0