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 379-386 sub CustomXSLTExportList { Link Here
379
    my $opac = shift; # opac (1) vs intranet (0)
380
    my $opac = shift; # opac (1) vs intranet (0)
380
    return [] if $opac && C4::Context->preference('OpacExportOptions') !~ /custom/;
381
    return [] if $opac && C4::Context->preference('OpacExportOptions') !~ /custom/;
381
382
382
    my @tabFiles;
383
    # Check the cache first
384
    my $cache = Koha::Caches->get_instance;
385
    my $key = $opac ? 'CustomXSLTExportListOPAC' : 'CustomXSLTExportListIntra';
386
    my $cached_val = $cache->get_from_cache($key);
387
    return $cached_val if $cached_val;
383
388
389
    my @tabFiles;
384
    my $dir = C4::Context->config( $opac ? 'opachtdocs' : 'intrahtdocs') .
390
    my $dir = C4::Context->config( $opac ? 'opachtdocs' : 'intrahtdocs') .
385
                      '/' . C4::Context->preference( $opac ? "opacthemes" : "template") .
391
                      '/' . C4::Context->preference( $opac ? "opacthemes" : "template") .
386
                      '/' . C4::Languages::getlanguage() .
392
                      '/' . C4::Languages::getlanguage() .
Lines 414-419 sub CustomXSLTExportList { Link Here
414
            push @tabFiles, \%row;
420
            push @tabFiles, \%row;
415
        }
421
        }
416
    }
422
    }
423
    $cache->set_in_cache( $key, [ @tabFiles ] );
417
    return \@tabFiles;
424
    return \@tabFiles;
418
}
425
}
419
426
(-)a/t/db_dependent/XSLT.t (-2 / +16 lines)
Lines 1-11 Link Here
1
use Modern::Perl;
1
use Modern::Perl;
2
use Test::More tests => 1;
2
use Test::More tests => 2;
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;
Lines 20-23 subtest 'CustomXSLTExportList: Check export options' => sub { Link Here
20
    $list = C4::XSLT::CustomXSLTExportList(1);
22
    $list = C4::XSLT::CustomXSLTExportList(1);
21
    is( @$list, 0, 'We expect an empty list now' );
23
    is( @$list, 0, 'We expect an empty list now' );
22
};
24
};
25
26
subtest  'CustomXSLTExportList: Caching' => sub {
27
    plan tests => 1;
28
    t::lib::Mocks::mock_preference('OpacExportOptions', 'custom');
29
    $cache->clear_from_cache('CustomXSLTExportListOPAC');
30
    my $list = C4::XSLT::CustomXSLTExportList(1);
31
    push @$list, { nonsense => 1 };
32
    $cache->set_in_cache( 'CustomXSLTExportListOPAC', $list );
33
    my $n = @$list;
34
    $list = C4::XSLT::CustomXSLTExportList(1);
35
    is( @$list, $n, 'This list comes from the cache and that is fine' );
36
    $cache->clear_from_cache('CustomXSLTExportListOPAC');
37
};
23
$schema->storage->txn_rollback;
38
$schema->storage->txn_rollback;
24
- 

Return to bug 17385