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

(-)a/Koha/CirculationRules.pm (-1 / +18 lines)
Lines 26-31 use Koha::CirculationRule; Link Here
26
use base qw(Koha::Objects);
26
use base qw(Koha::Objects);
27
27
28
use constant GUESSED_ITEMTYPES_KEY => 'Koha_IssuingRules_last_guess';
28
use constant GUESSED_ITEMTYPES_KEY => 'Koha_IssuingRules_last_guess';
29
use constant CACHE_NO_CIRCULATION_RULE_VALUE => 'NONE';
29
30
30
=head1 NAME
31
=head1 NAME
31
32
Lines 190-195 sub get_effective_rule { Link Here
190
        "Required parameter 'rule_name' missing")
191
        "Required parameter 'rule_name' missing")
191
      unless $rule_name;
192
      unless $rule_name;
192
193
194
    my $cache = Koha::Caches->get_instance();
195
    my $cache_key = 'CirculationRule_get_effective_rule-'.$rule_name;
196
    foreach ( $branchcode, $categorycode, $itemtype ) {
197
        $cache_key .= '-'.($_ ? $_ : '');
198
    }
199
    my $cached = $cache->get_from_cache($cache_key);
200
    if ($cached) {
201
        if ( ref $cached eq 'SCALAR' && $cached eq CACHE_NO_CIRCULATION_RULE_VALUE ) {
202
            return undef;
203
        }
204
        my $cr = Koha::CirculationRule->new($cached);
205
        $cr->{_result}->in_storage(1); # Tell it exists in DB
206
        return $cr;
207
    }
208
193
    for my $v ( $branchcode, $categorycode, $itemtype ) {
209
    for my $v ( $branchcode, $categorycode, $itemtype ) {
194
        $v = undef if $v and $v eq '*';
210
        $v = undef if $v and $v eq '*';
195
    }
211
    }
Lines 212-217 sub get_effective_rule { Link Here
212
        }
228
        }
213
    )->single;
229
    )->single;
214
230
231
    $cache->set_in_cache( $cache_key, $rule ? $rule->unblessed : CACHE_NO_CIRCULATION_RULE_VALUE );
232
215
    return $rule;
233
    return $rule;
216
}
234
}
217
235
218
- 

Return to bug 26393