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

(-)a/C4/XSLT.pm (-1 / +8 lines)
Lines 30-35 use C4::Biblio; Link Here
30
use C4::Circulation;
30
use C4::Circulation;
31
use C4::Reserves;
31
use C4::Reserves;
32
use Koha::AuthorisedValues;
32
use Koha::AuthorisedValues;
33
use Koha::Caches;
33
use Koha::ItemTypes;
34
use Koha::ItemTypes;
34
use Koha::XSLT_Handler;
35
use Koha::XSLT_Handler;
35
use Koha::Libraries;
36
use Koha::Libraries;
Lines 404-411 sub CustomXSLTExportList { Link Here
404
    my $opac = shift; # opac (1) vs intranet (0)
405
    my $opac = shift; # opac (1) vs intranet (0)
405
    return [] if $opac && C4::Context->preference('OpacExportOptions') !~ /custom/;
406
    return [] if $opac && C4::Context->preference('OpacExportOptions') !~ /custom/;
406
407
407
    my @tabFiles;
408
    # Check the cache first
409
    my $cache = Koha::Caches->get_instance;
410
    my $key = $opac ? 'CustomXSLTExportListOPAC' : 'CustomXSLTExportListIntra';
411
    my $cached_val = $cache->get_from_cache($key);
412
    return $cached_val if $cached_val;
408
413
414
    my @tabFiles;
409
    my $dir = C4::Context->config( $opac ? 'opachtdocs' : 'intrahtdocs') .
415
    my $dir = C4::Context->config( $opac ? 'opachtdocs' : 'intrahtdocs') .
410
                      '/' . C4::Context->preference( $opac ? "opacthemes" : "template") .
416
                      '/' . C4::Context->preference( $opac ? "opacthemes" : "template") .
411
                      '/' . C4::Languages::getlanguage() .
417
                      '/' . C4::Languages::getlanguage() .
Lines 439-444 sub CustomXSLTExportList { Link Here
439
            push @tabFiles, \%row;
445
            push @tabFiles, \%row;
440
        }
446
        }
441
    }
447
    }
448
    $cache->set_in_cache( $key, [ @tabFiles ] );
442
    return \@tabFiles;
449
    return \@tabFiles;
443
}
450
}
444
451
(-)a/t/db_dependent/XSLT.t (-2 / +16 lines)
Lines 1-11 Link Here
1
use Modern::Perl;
1
use Modern::Perl;
2
use Test::More tests => 1;
2
use Test::More tests => 2;
3
3
4
use t::lib::Mocks;
4
use t::lib::Mocks;
5
use C4::XSLT;
5
use C4::XSLT;
6
use Koha::Caches;
6
use Koha::Database;
7
use Koha::Database;
7
8
8
our $schema = Koha::Database->new->schema;
9
our $schema = Koha::Database->new->schema;
10
our $cache = Koha::Caches->get_instance;
9
11
10
# Here we go
12
# Here we go
11
$schema->storage->txn_begin;
13
$schema->storage->txn_begin;
Lines 20-23 subtest 'CustomXSLTExportList: Check export options' => sub { Link Here
20
    $list = C4::XSLT::CustomXSLTExportList(1);
22
    $list = C4::XSLT::CustomXSLTExportList(1);
21
    is( @$list, 0, 'We expect an empty list now' );
23
    is( @$list, 0, 'We expect an empty list now' );
22
};
24
};
25
26
subtest  'CustomXSLTExportList: Caching' => sub {
27
    plan tests => 1;
28
    t::lib::Mocks::mock_preference('OpacExportOptions', 'custom');
29
    $cache->clear_from_cache('CustomXSLTExportListOPAC');
30
    my $list = C4::XSLT::CustomXSLTExportList(1);
31
    push @$list, { nonsense => 1 };
32
    $cache->set_in_cache( 'CustomXSLTExportListOPAC', $list );
33
    my $n = @$list;
34
    $list = C4::XSLT::CustomXSLTExportList(1);
35
    is( @$list, $n, 'This list comes from the cache and that is fine' );
36
    $cache->clear_from_cache('CustomXSLTExportListOPAC');
37
};
23
$schema->storage->txn_rollback;
38
$schema->storage->txn_rollback;
24
- 

Return to bug 17385