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

(-)a/C4/XSLT.pm (+8 lines)
Lines 29-34 use C4::Biblio qw( GetAuthorisedValueDesc GetFrameworkCode GetMarcStructure ); Link Here
29
use Koha::AuthorisedValues;
29
use Koha::AuthorisedValues;
30
use Koha::ItemTypes;
30
use Koha::ItemTypes;
31
use Koha::RecordProcessor;
31
use Koha::RecordProcessor;
32
use Koha::Caches;
32
use Koha::XSLT::Base;
33
use Koha::XSLT::Base;
33
use Koha::Libraries;
34
use Koha::Libraries;
34
use Koha::Recalls;
35
use Koha::Recalls;
Lines 419-424 sub CustomXSLTExportList { Link Here
419
    my $opac = shift; # opac (1) vs intranet (0)
420
    my $opac = shift; # opac (1) vs intranet (0)
420
    return [] if $opac && C4::Context->preference('OpacExportOptions') !~ /custom/;
421
    return [] if $opac && C4::Context->preference('OpacExportOptions') !~ /custom/;
421
422
423
    # Check the cache first
424
    my $cache = Koha::Caches->get_instance;
425
    my $key = $opac ? 'CustomXSLTExportListOPAC' : 'CustomXSLTExportListIntra';
426
    my $cached_val = $cache->get_from_cache($key);
427
    return $cached_val if $cached_val;
428
422
    my @tabFiles;
429
    my @tabFiles;
423
430
424
    my $dir = C4::Context->config( $opac ? 'opachtdocs' : 'intrahtdocs') .
431
    my $dir = C4::Context->config( $opac ? 'opachtdocs' : 'intrahtdocs') .
Lines 455-460 sub CustomXSLTExportList { Link Here
455
            push @tabFiles, \%row;
462
            push @tabFiles, \%row;
456
        }
463
        }
457
    }
464
    }
465
    $cache->set_in_cache( $key, [ @tabFiles ] );
458
    return \@tabFiles;
466
    return \@tabFiles;
459
}
467
}
460
1;
468
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 'buildKohaItemsNamespace status tests' => sub {
35
subtest 'buildKohaItemsNamespace status tests' => sub {
33
- 

Return to bug 17385