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

(-)a/C4/XSLT.pm (-1 / +8 lines)
Lines 28-33 use C4::Koha qw( xml_escape ); Link Here
28
use C4::Biblio qw( GetAuthorisedValueDesc GetFrameworkCode GetMarcStructure );
28
use C4::Biblio qw( GetAuthorisedValueDesc GetFrameworkCode GetMarcStructure );
29
use Koha::AuthorisedValues;
29
use Koha::AuthorisedValues;
30
use Koha::ItemTypes;
30
use Koha::ItemTypes;
31
use Koha::Caches;
31
use Koha::XSLT::Base;
32
use Koha::XSLT::Base;
32
use Koha::Libraries;
33
use Koha::Libraries;
33
34
Lines 473-480 sub CustomXSLTExportList { Link Here
473
    my $opac = shift; # opac (1) vs intranet (0)
474
    my $opac = shift; # opac (1) vs intranet (0)
474
    return [] if $opac && C4::Context->preference('OpacExportOptions') !~ /custom/;
475
    return [] if $opac && C4::Context->preference('OpacExportOptions') !~ /custom/;
475
476
476
    my @tabFiles;
477
    # Check the cache first
478
    my $cache = Koha::Caches->get_instance;
479
    my $key = $opac ? 'CustomXSLTExportListOPAC' : 'CustomXSLTExportListIntra';
480
    my $cached_val = $cache->get_from_cache($key);
481
    return $cached_val if $cached_val;
477
482
483
    my @tabFiles;
478
    my $dir = C4::Context->config( $opac ? 'opachtdocs' : 'intrahtdocs') .
484
    my $dir = C4::Context->config( $opac ? 'opachtdocs' : 'intrahtdocs') .
479
                      '/' . C4::Context->preference( $opac ? "opacthemes" : "template") .
485
                      '/' . C4::Context->preference( $opac ? "opacthemes" : "template") .
480
                      '/' . C4::Languages::getlanguage() .
486
                      '/' . C4::Languages::getlanguage() .
Lines 509-514 sub CustomXSLTExportList { Link Here
509
            push @tabFiles, \%row;
515
            push @tabFiles, \%row;
510
        }
516
        }
511
    }
517
    }
518
    $cache->set_in_cache( $key, [ @tabFiles ] );
512
    return \@tabFiles;
519
    return \@tabFiles;
513
}
520
}
514
1;
521
1;
(-)a/t/db_dependent/XSLT.t (-8 / +12 lines)
Lines 6-32 use Test::Warn; Link Here
6
use t::lib::TestBuilder;
6
use t::lib::TestBuilder;
7
use t::lib::Mocks;
7
use t::lib::Mocks;
8
8
9
use C4::XSLT;
10
use Koha::Caches;
9
use Koha::Database;
11
use Koha::Database;
10
use Koha::Libraries;
12
use Koha::Libraries;
11
use Koha::ItemTypes;
13
use Koha::ItemTypes;
12
use C4::XSLT;
13
14
14
BEGIN {
15
BEGIN {
15
    use_ok('C4::XSLT', qw( transformMARCXML4XSLT getAuthorisedValues4MARCSubfields buildKohaItemsNamespace ));
16
    use_ok('C4::XSLT', qw( transformMARCXML4XSLT getAuthorisedValues4MARCSubfields buildKohaItemsNamespace ));
16
}
17
}
17
18
18
our $schema = Koha::Database->new->schema;
19
our $schema = Koha::Database->new->schema;
20
our $cache = Koha::Caches->get_instance;
19
21
20
# Here we go
22
# Here we go
21
$schema->storage->txn_begin;
23
$schema->storage->txn_begin;
22
subtest 'CustomXSLTExportList: Check export options' => sub {
24
subtest  'CustomXSLTExportList: Caching' => sub {
23
    plan tests => 2;
25
    plan tests => 1;
24
    t::lib::Mocks::mock_preference('OpacExportOptions', 'custom');
26
    t::lib::Mocks::mock_preference('OpacExportOptions', 'custom');
25
        my $list = C4::XSLT::CustomXSLTExportList(1);
27
    $cache->clear_from_cache('CustomXSLTExportListOPAC');
26
    is( @$list>0, 1, 'We expect at least one result: simple export' );
28
    my $list = C4::XSLT::CustomXSLTExportList(1);
27
    t::lib::Mocks::mock_preference('OpacExportOptions', 'dc');
29
    push @$list, { nonsense => 1 };
30
    $cache->set_in_cache( 'CustomXSLTExportListOPAC', $list );
31
    my $n = @$list;
28
    $list = C4::XSLT::CustomXSLTExportList(1);
32
    $list = C4::XSLT::CustomXSLTExportList(1);
29
    is( @$list, 0, 'We expect an empty list now' );
33
    is( @$list, $n, 'This list comes from the cache and that is fine' );
34
    $cache->clear_from_cache('CustomXSLTExportListOPAC');
30
};
35
};
31
36
32
subtest 'transformMARCXML4XSLT tests' => sub {
37
subtest 'transformMARCXML4XSLT tests' => sub {
33
- 

Return to bug 17385