From 35d12e58698e20d6930b45a3ad3c6778a6bf2e69 Mon Sep 17 00:00:00 2001
From: Robin Sheat <robin@catalyst.net.nz>
Date: Tue, 3 Jun 2014 10:41:46 +1200
Subject: [PATCH] Bug 9967 - include $branch_limit in the cache key

Make the caching more correct. Also removes a warn that got left behind.

Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
---
 C4/Koha.pm | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/C4/Koha.pm b/C4/Koha.pm
index 2e47cc9..e4640d2 100644
--- a/C4/Koha.pm
+++ b/C4/Koha.pm
@@ -1140,16 +1140,16 @@ sub GetAuthorisedValues {
     # what it's for.
 
     # Is this cached already?
-    $opac = $opac ? 1 : 0; # normalise to be safe
+    $opac = $opac ? 1 : 0;    # normalise to be safe
+    my $branch_limit =
+      C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
     my $selected_key = defined($selected) ? $selected : '';
-    my $cache_key = "AuthorisedValues-$category-$selected_key-$opac";
-    my $cache     = Koha::Cache->get_instance();
-    my $result    = $cache->get_from_cache($cache_key);
-warn "fetched $result from cache";
+    my $cache_key =
+      "AuthorisedValues-$category-$selected_key-$opac-$branch_limit";
+    my $cache  = Koha::Cache->get_instance();
+    my $result = $cache->get_from_cache($cache_key);
     return $result if $result;
 
-    my $branch_limit =
-      C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
     my @results;
     my $dbh      = C4::Context->dbh;
     my $query = qq{
-- 
2.1.0