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

(-)a/C4/Context.pm (-1 / +20 lines)
Lines 487-497 my %sysprefs; Link Here
487
sub preference {
487
sub preference {
488
    my $self = shift;
488
    my $self = shift;
489
    my $var  = lc(shift);                          # The system preference to return
489
    my $var  = lc(shift);                          # The system preference to return
490
    my $cache;
490
491
491
    if (exists $sysprefs{$var}) {
492
    if (exists $sysprefs{$var}) {
492
        return $sysprefs{$var};
493
        return $sysprefs{$var};
493
    }
494
    }
494
495
496
    if (Koha::Cache->is_cache_active()) {
497
        $cache = Koha::Cache->new();
498
        if (defined $cache) {
499
            $sysprefs{$var} = $cache->get_from_cache("syspref:$var");
500
            return $sysprefs{$var} if (defined $sysprefs{$var});
501
        }
502
    }
503
495
    my $dbh  = C4::Context->dbh or return 0;
504
    my $dbh  = C4::Context->dbh or return 0;
496
505
497
    # Look up systempreferences.variable==$var
506
    # Look up systempreferences.variable==$var
Lines 502-507 sub preference { Link Here
502
        LIMIT    1
511
        LIMIT    1
503
END_SQL
512
END_SQL
504
    $sysprefs{$var} = $dbh->selectrow_array( $sql, {}, $var );
513
    $sysprefs{$var} = $dbh->selectrow_array( $sql, {}, $var );
514
    if (Koha::Cache->is_cache_active() && defined $cache) {
515
        $cache->set_in_cache("syspref:$var");
516
    }
505
    return $sysprefs{$var};
517
    return $sysprefs{$var};
506
}
518
}
507
519
Lines 524-529 will not be seen by this process. Link Here
524
536
525
sub clear_syspref_cache {
537
sub clear_syspref_cache {
526
    %sysprefs = ();
538
    %sysprefs = ();
539
    if (Koha::Cache->is_cache_active()) {
540
        my $cache = Koha::Cache->new();
541
        $cache->flush_all() if defined $cache; # Sorry, this is unpleasant
542
    }
527
}
543
}
528
544
529
=head2 set_preference
545
=head2 set_preference
Lines 554-559 sub set_preference { Link Here
554
    " );
570
    " );
555
571
556
    if($sth->execute( $var, $value )) {
572
    if($sth->execute( $var, $value )) {
573
        if (Koha::Cache->is_cache_active()) {
574
            my $cache = Koha::Cache->new();
575
            $cache->set_in_cache("syspref:$var", $value) if defined $cache;
576
        }
557
        $sysprefs{$var} = $value;
577
        $sysprefs{$var} = $value;
558
    }
578
    }
559
    $sth->finish;
579
    $sth->finish;
560
- 

Return to bug 8089