View | Details | Raw Unified | Return to bug 16229
Collapse All | Expand All

(-)a/Koha/Cache.pm (+2 lines)
Lines 335-340 sub get_from_cache { Link Here
335
    # Otherwise the L1 cache won't ever be populated
335
    # Otherwise the L1 cache won't ever be populated
336
    $L1_cache{$key} = $value;
336
    $L1_cache{$key} = $value;
337
337
338
    $value = clone $value if ref $L1_cache{$key} and not $unsafe;
339
338
    return $value;
340
    return $value;
339
}
341
}
340
342
(-)a/t/Cache.t (-2 / +7 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 37;
20
use Test::More tests => 38;
21
21
22
my $destructorcount = 0;
22
my $destructorcount = 0;
23
23
Lines 181-186 SKIP: { Link Here
181
    $item_from_cache = $cache->get_from_cache('test_deep_copy_array');
181
    $item_from_cache = $cache->get_from_cache('test_deep_copy_array');
182
    @$item_from_cache = qw( another array ref );
182
    @$item_from_cache = qw( another array ref );
183
    is_deeply( $cache->get_from_cache('test_deep_copy_array'), [ qw ( an array ref ) ], 'An array will be deep copied');
183
    is_deeply( $cache->get_from_cache('test_deep_copy_array'), [ qw ( an array ref ) ], 'An array will be deep copied');
184
185
    $cache->flush_L1_cache();
186
    $item_from_cache = $cache->get_from_cache('test_deep_copy_array');
187
    @$item_from_cache = qw( another array ref );
188
    is_deeply( $cache->get_from_cache('test_deep_copy_array'), [ qw ( an array ref ) ], 'An array will be deep copied even it is the first fetch from L2');
189
184
    $item_from_cache = $cache->get_from_cache('test_deep_copy_array', { unsafe => 1 });
190
    $item_from_cache = $cache->get_from_cache('test_deep_copy_array', { unsafe => 1 });
185
    @$item_from_cache = qw( another array ref );
191
    @$item_from_cache = qw( another array ref );
186
    is_deeply( $cache->get_from_cache('test_deep_copy_array'), [ qw ( another array ref ) ], 'An array will not be deep copied if the unsafe flag is set');
192
    is_deeply( $cache->get_from_cache('test_deep_copy_array'), [ qw ( another array ref ) ], 'An array will not be deep copied if the unsafe flag is set');
187
- 

Return to bug 16229