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 414-421 sub CustomXSLTExportList { Link Here
414
    my $opac = shift; # opac (1) vs intranet (0)
415
    my $opac = shift; # opac (1) vs intranet (0)
415
    return [] if $opac && C4::Context->preference('OpacExportOptions') !~ /custom/;
416
    return [] if $opac && C4::Context->preference('OpacExportOptions') !~ /custom/;
416
417
417
    my @tabFiles;
418
    # Check the cache first
419
    my $cache = Koha::Caches->get_instance;
420
    my $key = $opac ? 'CustomXSLTExportListOPAC' : 'CustomXSLTExportListIntra';
421
    my $cached_val = $cache->get_from_cache($key);
422
    return $cached_val if $cached_val;
418
423
424
    my @tabFiles;
419
    my $dir = C4::Context->config( $opac ? 'opachtdocs' : 'intrahtdocs') .
425
    my $dir = C4::Context->config( $opac ? 'opachtdocs' : 'intrahtdocs') .
420
                      '/' . C4::Context->preference( $opac ? "opacthemes" : "template") .
426
                      '/' . C4::Context->preference( $opac ? "opacthemes" : "template") .
421
                      '/' . C4::Languages::getlanguage() .
427
                      '/' . C4::Languages::getlanguage() .
Lines 449-454 sub CustomXSLTExportList { Link Here
449
            push @tabFiles, \%row;
455
            push @tabFiles, \%row;
450
        }
456
        }
451
    }
457
    }
458
    $cache->set_in_cache( $key, [ @tabFiles ] );
452
    return \@tabFiles;
459
    return \@tabFiles;
453
}
460
}
454
461
(-)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 $item  = $builder->build_sample_item({});
28
    my $item  = $builder->build_sample_item({});
25
- 

Return to bug 17385