Bugzilla – Attachment 50236 Details for
Bug 16229
Koha::Cache should be on the safe side
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16229: Deep copy on setting in cache
Bug-16229-Deep-copy-on-setting-in-cache.patch (text/plain), 1.83 KB, created by
Tomás Cohen Arazi (tcohen)
on 2016-04-14 13:52:02 UTC
(
hide
)
Description:
Bug 16229: Deep copy on setting in cache
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2016-04-14 13:52:02 UTC
Size:
1.83 KB
patch
obsolete
>From a7bba7fac819c723cf74d7b2c54b7d6a3294b750 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 8 Apr 2016 12:43:48 +0100 >Subject: [PATCH] Bug 16229: Deep copy on setting in cache > >Koha::Cache->set_in_cache should deep copy (if needed) to avoid the >value which has been set in cache to be unintentionally modified later. > >Signed-off-by: Jacek Ablewicz <abl@biblos.pk.edu.pl> >Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar> >--- > Koha/Cache.pm | 1 + > t/Cache.t | 4 +++- > 2 files changed, 4 insertions(+), 1 deletion(-) > >diff --git a/Koha/Cache.pm b/Koha/Cache.pm >index 0c9558d..c717c5a 100644 >--- a/Koha/Cache.pm >+++ b/Koha/Cache.pm >@@ -281,6 +281,7 @@ sub set_in_cache { > $expiry //= $self->{timeout}; > my $set_sub = $self->{ref($self->{$cache}) . "_set"}; > >+ $value = clone $value; > # Set in L1 cache > $L1_cache{ $key } = $value; > >diff --git a/t/Cache.t b/t/Cache.t >index fa20a45..8fa96e6 100644 >--- a/t/Cache.t >+++ b/t/Cache.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 38; >+use Test::More tests => 39; > > my $destructorcount = 0; > >@@ -196,6 +196,8 @@ SKIP: { > $item_from_cache = $cache->get_from_cache('test_deep_copy_hash'); > %$item_from_cache = ( another => 'hashref' ); > is_deeply( $cache->get_from_cache('test_deep_copy_hash'), { a => 'hashref' }, 'A hash will be deep copied'); >+ %item = ( a_modified => 'hashref' ); >+ is_deeply( $cache->get_from_cache('test_deep_copy_hash'), { a => 'hashref' }, 'A hash will be deep copied when set in cache'); > $item_from_cache = $cache->get_from_cache('test_deep_copy_hash', { unsafe => 1}); > %$item_from_cache = ( another => 'hashref' ); > is_deeply( $cache->get_from_cache('test_deep_copy_hash'), { another => 'hashref' }, 'A hash will not be deep copied if the unsafe flag is set'); >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 16229
:
50072
|
50073
|
50074
|
50076
|
50199
|
50200
|
50201
|
50235
| 50236 |
50237
|
50238