use JSON rather than Storable for the OPAC search history cookie
[koha.git] / C4 / Auth.pm
index d6e088a..9d80ab6 100644 (file)
@@ -20,7 +20,7 @@ package C4::Auth;
 use strict;
 use warnings;
 use Digest::MD5 qw(md5_base64);
-use Storable qw(thaw freeze);
+use JSON qw/encode_json decode_json/;
 use URI::Escape;
 use CGI::Session;
 
@@ -254,7 +254,7 @@ sub get_template_and_user {
             my $searchcookie = $in->{'query'}->cookie('KohaOpacRecentSearches');
             if ($searchcookie){
                 $searchcookie = uri_unescape($searchcookie);
-                    my @recentSearches = @{thaw($searchcookie) || []};
+                    my @recentSearches = @{decode_json($searchcookie) || []};
                 if (@recentSearches) {
                     my $sth = $dbh->prepare($SEARCH_HISTORY_INSERT_SQL);
                     $sth->execute( $borrowernumber,
@@ -268,7 +268,7 @@ sub get_template_and_user {
                     # And then, delete the cookie's content
                     my $newsearchcookie = $in->{'query'}->cookie(
                                                 -name => 'KohaOpacRecentSearches',
-                                                -value => freeze([]),
+                                                -value => encode_json([]),
                                                 -HttpOnly => 1,
                                                 -expires => ''
                                              );
@@ -293,7 +293,7 @@ sub get_template_and_user {
         my $searchcookie = $in->{'query'}->cookie('KohaOpacRecentSearches');
         if ($searchcookie){
             $searchcookie = uri_unescape($searchcookie);
-                my @recentSearches = @{thaw($searchcookie) || []};
+                my @recentSearches = @{decode_json($searchcookie) || []};
          # We show the link in opac
             if (@recentSearches) {
                 $template->param(ShowOpacRecentSearchLink => 1);