use a separate anon cache session for cart
authorGalen Charlton <gmc@equinoxinitiative.org>
Tue, 5 Jun 2018 21:42:59 +0000 (17:42 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Tue, 5 Jun 2018 21:42:59 +0000 (17:42 -0400)
This works around the staffsearches anoncache handling stomping
over the cart when the OPAC is embedded, as open-ils.actor.anon_cache.get_value
currently can't distinguish between an invalid session key and a case
where the sub-key is not yet populated in the anon cache value.

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Container.pm
Open-ILS/web/js/ui/default/staff/cat/catalog/app.js

index d2dd2af..df320a6 100644 (file)
@@ -36,7 +36,8 @@ use constant COOKIE_PHYSICAL_LOC => 'eg_physical_loc';
 use constant COOKIE_SSS_EXPAND => 'eg_sss_expand';
 
 use constant COOKIE_ANON_CACHE => 'anoncache';
-use constant ANON_CACHE_MYLIST => 'mylist';
+use constant COOKIE_CART_CACHE => 'cartcache';
+use constant CART_CACHE_MYLIST => 'mylist';
 use constant ANON_CACHE_STAFF_SEARCH => 'staffsearch';
 
 use constant DEBUG_TIMING => 0;
index d2cb53e..00d6a2e 100644 (file)
@@ -13,14 +13,14 @@ sub fetch_mylist {
     my ($self, $with_marc_xml, $skip_sort) = @_;
 
     my $list = [];
-    my $cache_key = $self->cgi->cookie((ref $self)->COOKIE_ANON_CACHE);
+    my $cache_key = $self->cgi->cookie((ref $self)->COOKIE_CART_CACHE);
 
     if($cache_key) {
 
         $list = $U->simplereq(
             'open-ils.actor',
             'open-ils.actor.anon_cache.get_value', 
-            $cache_key, (ref $self)->ANON_CACHE_MYLIST);
+            $cache_key, (ref $self)->CART_CACHE_MYLIST);
 
         if(!$list) {
             $cache_key = undef;
@@ -99,7 +99,7 @@ sub load_api_mylist_add {
     };
     $self->ctx->{json_reponse_cookie} =
         $self->cgi->cookie(
-            -name => (ref $self)->COOKIE_ANON_CACHE,
+            -name => (ref $self)->COOKIE_CART_CACHE,
             -path => '/',
             -value => ($cache_key) ? $cache_key : '',
             -expires => ($cache_key) ? undef : '-1h'
@@ -118,7 +118,7 @@ sub _do_mylist_add {
     $cache_key = $U->simplereq(
         'open-ils.actor',
         'open-ils.actor.anon_cache.set_value', 
-        $cache_key, (ref $self)->ANON_CACHE_MYLIST, $list);
+        $cache_key, (ref $self)->CART_CACHE_MYLIST, $list);
 
     return ($cache_key, $list);
 }
@@ -141,7 +141,7 @@ sub load_api_mylist_delete {
     };
     $self->ctx->{json_reponse_cookie} =
         $self->cgi->cookie(
-            -name => (ref $self)->COOKIE_ANON_CACHE,
+            -name => (ref $self)->COOKIE_CART_CACHE,
             -path => '/',
             -value => ($cache_key) ? $cache_key : '',
             -expires => ($cache_key) ? undef : '-1h'
@@ -162,7 +162,7 @@ sub _do_mylist_delete {
     $cache_key = $U->simplereq(
         'open-ils.actor',
         'open-ils.actor.anon_cache.set_value', 
-        $cache_key, (ref $self)->ANON_CACHE_MYLIST, $list);
+        $cache_key, (ref $self)->CART_CACHE_MYLIST, $list);
 
     return ($cache_key, $list);
 }
@@ -170,7 +170,7 @@ sub _do_mylist_delete {
 sub load_mylist_print {
     my $self = shift;
 
-    my $cache_key = shift // $self->cgi->cookie((ref $self)->COOKIE_ANON_CACHE);
+    my $cache_key = shift // $self->cgi->cookie((ref $self)->COOKIE_CART_CACHE);
 
     if (!$cache_key) {
         return $self->generic_redirect;
@@ -196,7 +196,7 @@ sub load_mylist_print {
 sub load_mylist_email {
     my $self = shift;
 
-    my $cache_key = $self->cgi->cookie((ref $self)->COOKIE_ANON_CACHE);
+    my $cache_key = $self->cgi->cookie((ref $self)->COOKIE_CART_CACHE);
 
     if (!$cache_key) {
         return $self->generic_redirect;
@@ -226,7 +226,7 @@ sub _stash_record_list_in_anon_cache {
     my $cache_key = $U->simplereq(
         'open-ils.actor',
         'open-ils.actor.anon_cache.set_value',
-        undef, (ref $self)->ANON_CACHE_MYLIST, [ @rec_ids ]);
+        undef, (ref $self)->CART_CACHE_MYLIST, [ @rec_ids ]);
     return $cache_key;
 }
 
@@ -259,7 +259,7 @@ sub load_mylist_move {
     $cache_key = $U->simplereq(
         'open-ils.actor',
         'open-ils.actor.anon_cache.set_value', 
-        $cache_key, (ref $self)->ANON_CACHE_MYLIST, \@keep
+        $cache_key, (ref $self)->CART_CACHE_MYLIST, \@keep
     );
 
     if ($self->ctx->{user} and $action =~ /^\d+$/) {
@@ -282,7 +282,7 @@ sub clear_anon_cache {
     my $self = shift;
     my $field = shift;
 
-    my $cache_key = $self->cgi->cookie((ref $self)->COOKIE_ANON_CACHE) or return;
+    my $cache_key = $self->cgi->cookie((ref $self)->COOKIE_CART_CACHE) or return;
 
     $U->simplereq(
         'open-ils.actor',
@@ -310,7 +310,7 @@ sub mylist_action_redirect {
     return $self->generic_redirect(
         $url,
         $self->cgi->cookie(
-            -name => (ref $self)->COOKIE_ANON_CACHE,
+            -name => (ref $self)->COOKIE_CART_CACHE,
             -path => '/',
             -value => ($cache_key) ? $cache_key : '',
             -expires => ($cache_key) ? undef : '-1h'
@@ -342,7 +342,7 @@ sub mylist_warning_redirect {
     return $self->generic_redirect(
         $base_url,
         $self->cgi->cookie(
-            -name => (ref $self)->COOKIE_ANON_CACHE,
+            -name => (ref $self)->COOKIE_CART_CACHE,
             -path => '/',
             -value => ($cache_key) ? $cache_key : '',
             -expires => ($cache_key) ? undef : '-1h'
index 62e4cfc..35a72bc 100644 (file)
@@ -319,7 +319,7 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
     }
 
     $scope.add_cart_to_record_bucket = function() {
-        var cartkey = $cookies.get('anoncache');
+        var cartkey = $cookies.get('cartcache');
         if (!cartkey) return;
         egCore.net.request(
             'open-ils.actor',