From 799ac3cb869adc134bd1aa420fc99a79b335ad24 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 4 May 2016 19:43:43 +0100 Subject: [PATCH] Bug 16441: Do not use a package variable to cache C4::Letters::getletter MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit C4::Letters::getletter use a package variable (%letter) to cache letter returned by the subroutine. I have not found any direct issues caused by that but it is safer to remove it. It won't be a big deal to hit the DBMS to get a valid letter when needed. No test plan here, just confirm that the changes make sense. Signed-off-by: Srdjan Signed-off-by: Marcel de Rooy Confirm that performance loss is just a millisecond or so per subsequent call of getletter. Signed-off-by: Kyle M Hall (cherry picked from commit c4f388f64966f2202e9f3e3c16dad5cef3dbe0ac) Signed-off-by: Frédéric Demians (cherry picked from commit c63dccba27842ce92569625a03df55085bf5681a) Signed-off-by: Julian Maurice --- C4/Letters.pm | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index 67753dcbb1..dfae01e2f2 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -200,12 +200,6 @@ sub GetLettersAvailableForALibrary { } -# FIXME: using our here means that a Plack server will need to be -# restarted fairly regularly when working with this routine. -# A better option would be to use Koha::Cache and use a cache -# that actually works in a persistent environment, but as a -# short-term fix, our will work. -our %letter; sub getletter { my ( $module, $code, $branchcode, $message_transport_type ) = @_; $message_transport_type //= '%'; @@ -218,10 +212,6 @@ sub getletter { } $branchcode //= ''; - if ( my $l = $letter{$module}{$code}{$branchcode}{$message_transport_type} ) { - return { %$l }; # deep copy - } - my $dbh = C4::Context->dbh; my $sth = $dbh->prepare(q{ SELECT * @@ -234,7 +224,6 @@ sub getletter { my $line = $sth->fetchrow_hashref or return; $line->{'content-type'} = 'text/html; charset="UTF-8"' if $line->{is_html}; - $letter{$module}{$code}{$branchcode}{$message_transport_type} = $line; return { %$line }; } -- 2.39.5