Bug 16412: Cache undef in L1 only

No need to cache undef in L2.
Prevent numerous warnings like:
Use of uninitialized value in subroutine entry at /usr/share/koha/masterclone/Koha/Cache.pm line 284

Test plan:
Run t/Cache.t
Run t/db_dependent/sysprefs.t

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Amended patch: remove trailing space char and replace 'you' with 'we' to
match existing wordings.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jesse Weaver <jweaver@bywatersolutions.com>
(cherry picked from commit 7a452ac414)
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
This commit is contained in:
Marcel de Rooy 2016-05-02 12:26:44 +02:00 committed by Julian Maurice
parent 337e887460
commit 7db08616f2
1 changed files with 3 additions and 2 deletions

View File

@ -271,10 +271,11 @@ sub set_in_cache {
# Deep copy if it's not a scalar and unsafe is not passed
$value = dclone( $value ) if ref($value) and not $unsafe;
# Set in L1 cache
# Set in L1 cache; exit if we are caching an undef
$L1_cache{ $key } = $value;
return if !defined $value;
# We consider an expiry of 0 to be inifinite
# We consider an expiry of 0 to be infinite
if ( $expiry ) {
return $set_sub
? $set_sub->( $key, $value, $expiry )