Bug 34051: Cache empty hashref for non-existent authorised values
When fetching authorised value descriptions, we need to handle scenarios where a value doesn't exist in the cache and doesn't exist in the database. In this situation, we return an empty hashref, and this patch makes us cache this empty hashref. This is important because otherwise the function Koha::AuthorisedValues->get_description_by_koha_field will do a database call every time it encounters the same value that doesn't exist in the authorised values table. Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
7c05333914
commit
a3a0aaec10
|
|
@ -110,7 +110,10 @@ sub get_description_by_koha_field {
|
|||
return $cached if $cached;
|
||||
|
||||
my $av = $self->find_by_koha_field($params);
|
||||
return {} unless defined $av;
|
||||
if ( ! defined $av ){
|
||||
$memory_cache->set_in_cache( $cache_key, {} );
|
||||
return {};
|
||||
}
|
||||
my $descriptions = { lib => $av->lib, opac_description => $av->opac_description };
|
||||
$memory_cache->set_in_cache( $cache_key, $descriptions );
|
||||
return $descriptions;
|
||||
|
|
|
|||
Loading…
Reference in New Issue