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

(-)a/C4/XSLT.pm (+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
use Koha::Recalls;
34
use Koha::Recalls;
Lines 485-490 sub CustomXSLTExportList { Link Here
485
    my $opac = shift; # opac (1) vs intranet (0)
486
    my $opac = shift; # opac (1) vs intranet (0)
486
    return [] if $opac && C4::Context->preference('OpacExportOptions') !~ /custom/;
487
    return [] if $opac && C4::Context->preference('OpacExportOptions') !~ /custom/;
487
488
489
    # Check the cache first
490
    my $cache = Koha::Caches->get_instance;
491
    my $key = $opac ? 'CustomXSLTExportListOPAC' : 'CustomXSLTExportListIntra';
492
    my $cached_val = $cache->get_from_cache($key);
493
    return $cached_val if $cached_val;
494
488
    my @tabFiles;
495
    my @tabFiles;
489
496
490
    my $dir = C4::Context->config( $opac ? 'opachtdocs' : 'intrahtdocs') .
497
    my $dir = C4::Context->config( $opac ? 'opachtdocs' : 'intrahtdocs') .
Lines 521-526 sub CustomXSLTExportList { Link Here
521
            push @tabFiles, \%row;
528
            push @tabFiles, \%row;
522
        }
529
        }
523
    }
530
    }
531
    $cache->set_in_cache( $key, [ @tabFiles ] );
524
    return \@tabFiles;
532
    return \@tabFiles;
525
}
533
}
526
1;
534
1;
(-)a/t/db_dependent/XSLT.t (-7 / +9 lines)
Lines 19-32 our $schema = Koha::Database->new->schema; Link Here
19
19
20
# Here we go
20
# Here we go
21
$schema->storage->txn_begin;
21
$schema->storage->txn_begin;
22
subtest 'CustomXSLTExportList: Check export options' => sub {
22
subtest  'CustomXSLTExportList: Caching' => sub {
23
    plan tests => 2;
23
    plan tests => 1;
24
    t::lib::Mocks::mock_preference('OpacExportOptions', 'custom');
24
    t::lib::Mocks::mock_preference('OpacExportOptions', 'custom');
25
        my $list = C4::XSLT::CustomXSLTExportList(1);
25
    $cache->clear_from_cache('CustomXSLTExportListOPAC');
26
    is( @$list>0, 1, 'We expect at least one result: simple export' );
26
    my $list = C4::XSLT::CustomXSLTExportList(1);
27
    t::lib::Mocks::mock_preference('OpacExportOptions', 'dc');
27
    push @$list, { nonsense => 1 };
28
    $cache->set_in_cache( 'CustomXSLTExportListOPAC', $list );
29
    my $n = @$list;
28
    $list = C4::XSLT::CustomXSLTExportList(1);
30
    $list = C4::XSLT::CustomXSLTExportList(1);
29
    is( @$list, 0, 'We expect an empty list now' );
31
    is( @$list, $n, 'This list comes from the cache and that is fine' );
32
    $cache->clear_from_cache('CustomXSLTExportListOPAC');
30
};
33
};
31
34
32
subtest 'transformMARCXML4XSLT tests' => sub {
35
subtest 'transformMARCXML4XSLT tests' => sub {
33
- 

Return to bug 17385