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

(-)a/C4/XSLT.pm (-1 / +8 lines)
Lines 31-36 use C4::Circulation; Link Here
31
use C4::Reserves;
31
use C4::Reserves;
32
use Koha::AuthorisedValues;
32
use Koha::AuthorisedValues;
33
use Koha::ItemTypes;
33
use Koha::ItemTypes;
34
use Koha::Caches;
34
use Koha::XSLT::Base;
35
use Koha::XSLT::Base;
35
use Koha::Libraries;
36
use Koha::Libraries;
36
37
Lines 420-427 sub CustomXSLTExportList { Link Here
420
    my $opac = shift; # opac (1) vs intranet (0)
421
    my $opac = shift; # opac (1) vs intranet (0)
421
    return [] if $opac && C4::Context->preference('OpacExportOptions') !~ /custom/;
422
    return [] if $opac && C4::Context->preference('OpacExportOptions') !~ /custom/;
422
423
423
    my @tabFiles;
424
    # Check the cache first
425
    my $cache = Koha::Caches->get_instance;
426
    my $key = $opac ? 'CustomXSLTExportListOPAC' : 'CustomXSLTExportListIntra';
427
    my $cached_val = $cache->get_from_cache($key);
428
    return $cached_val if $cached_val;
424
429
430
    my @tabFiles;
425
    my $dir = C4::Context->config( $opac ? 'opachtdocs' : 'intrahtdocs') .
431
    my $dir = C4::Context->config( $opac ? 'opachtdocs' : 'intrahtdocs') .
426
                      '/' . C4::Context->preference( $opac ? "opacthemes" : "template") .
432
                      '/' . C4::Context->preference( $opac ? "opacthemes" : "template") .
427
                      '/' . C4::Languages::getlanguage() .
433
                      '/' . C4::Languages::getlanguage() .
Lines 456-461 sub CustomXSLTExportList { Link Here
456
            push @tabFiles, \%row;
462
            push @tabFiles, \%row;
457
        }
463
        }
458
    }
464
    }
465
    $cache->set_in_cache( $key, [ @tabFiles ] );
459
    return \@tabFiles;
466
    return \@tabFiles;
460
}
467
}
461
1;
468
1;
(-)a/t/db_dependent/XSLT.t (-8 / +11 lines)
Lines 3-24 use Test::More tests => 2; Link Here
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;
12
subtest 'CustomXSLTExportList: Check export options' => sub {
14
subtest  'CustomXSLTExportList: Caching' => sub {
13
    plan tests => 2;
15
    plan tests => 1;
14
    t::lib::Mocks::mock_preference('OpacExportOptions', 'custom');
16
    t::lib::Mocks::mock_preference('OpacExportOptions', 'custom');
15
        my $list = C4::XSLT::CustomXSLTExportList(1);
17
    $cache->clear_from_cache('CustomXSLTExportListOPAC');
16
    is( @$list>0, 1, 'We expect at least one result: simple export' );
18
    my $list = C4::XSLT::CustomXSLTExportList(1);
17
    t::lib::Mocks::mock_preference('OpacExportOptions', 'dc');
19
    push @$list, { nonsense => 1 };
20
    $cache->set_in_cache( 'CustomXSLTExportListOPAC', $list );
21
    my $n = @$list;
18
    $list = C4::XSLT::CustomXSLTExportList(1);
22
    $list = C4::XSLT::CustomXSLTExportList(1);
19
    is( @$list, 0, 'We expect an empty list now' );
23
    is( @$list, $n, 'This list comes from the cache and that is fine' );
24
    $cache->clear_from_cache('CustomXSLTExportListOPAC');
20
};
25
};
21
22
subtest 'buildKohaItemsNamespace status tests' => sub {
26
subtest 'buildKohaItemsNamespace status tests' => sub {
23
    plan tests => 13;
27
    plan tests => 13;
24
    my $itype = $builder->build_object({ class => 'Koha::ItemTypes' });
28
    my $itype = $builder->build_object({ class => 'Koha::ItemTypes' });
25
- 

Return to bug 17385