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;
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,
# And then, delete the cookie's content
my $newsearchcookie = $in->{'query'}->cookie(
-name => 'KohaOpacRecentSearches',
- -value => freeze([]),
+ -value => encode_json([]),
-HttpOnly => 1,
-expires => ''
);
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);
use C4::Auth qw(:DEFAULT get_session);
use CGI;
-use Storable qw(freeze thaw);
+use JSON qw/decode_json encode_json/;
use C4::Context;
use C4::Output;
use C4::Log;
# Deleting cookie's content
my $recentSearchesCookie = $cgi->cookie(
-name => 'KohaOpacRecentSearches',
- -value => freeze([]),
+ -value => encode_json([]),
-expires => ''
);
# Getting the cookie
my $searchcookie = $cgi->cookie('KohaOpacRecentSearches');
- if ($searchcookie && thaw(uri_unescape($searchcookie))) {
- my @recentSearches = @{thaw(uri_unescape($searchcookie))};
+ if ($searchcookie && decode_json(uri_unescape($searchcookie))) {
+ my @recentSearches = @{decode_json(uri_unescape($searchcookie))};
if (@recentSearches) {
# As the dates are stored as unix timestamps, let's do some formatting
use POSIX qw(ceil floor strftime);
use URI::Escape;
-use Storable qw(thaw freeze);
+use JSON qw/decode_json encode_json/;
use Business::ISBN;
my $DisplayMultiPlaceHold = C4::Context->preference("DisplayMultiPlaceHold");
my $searchcookie = $cgi->cookie('KohaOpacRecentSearches');
if ($searchcookie){
$searchcookie = uri_unescape($searchcookie);
- if (thaw($searchcookie)) {
- @recentSearches = @{thaw($searchcookie)};
+ if (decode_json($searchcookie)) {
+ @recentSearches = @{decode_json($searchcookie)};
}
}
# To a cookie (the user is not logged in)
if (!$offset) {
push @recentSearches, {
- "query_desc" => $query_desc_history || "unknown",
- "query_cgi" => $query_cgi_history || "unknown",
+ "query_desc" => Encode::decode_utf8($query_desc_history) || "unknown",
+ "query_cgi" => Encode::decode_utf8($query_cgi_history) || "unknown",
"time" => time(),
"total" => $total
};
# Pushing the cookie back
$newsearchcookie = $cgi->cookie(
-name => 'KohaOpacRecentSearches',
- # We uri_escape the whole freezed structure so we're sure we won't have any encoding problems
- -value => uri_escape( freeze(\@recentSearches) ),
+ # We uri_escape the whole serialized structure so we're sure we won't have any encoding problems
+ -value => uri_escape( encode_json(\@recentSearches) ),
-expires => ''
);
$cookie = [$cookie, $newsearchcookie];