From: Galen Charlton Date: Tue, 5 Jun 2018 21:42:59 +0000 (-0400) Subject: use a separate anon cache session for cart X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=78bcbe8ccbcc6a0e0996d40cd20d8b978823a5c6;p=working%2FEvergreen.git use a separate anon cache session for cart 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 --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm index d2dd2af759..df320a63ee 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm @@ -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; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Container.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Container.pm index d2cb53ec30..00d6a2e277 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Container.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Container.pm @@ -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' diff --git a/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js b/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js index 62e4cfc55d..35a72bc8aa 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js @@ -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',