From ab1b58b9ed68fe23f450c54673c81599533b7a07 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 22 Mar 2019 08:03:16 +0000 Subject: [PATCH] Bug 17385: (QA follow-up) Do not needlessly scan biblioexport folder Content-Type: text/plain; charset=utf-8 Performance: We need to return an empty list if OpacExportOptions does not contain Custom. No need to scan the directory for custom files, if we are not using them at all. Note: The test only pertains to OPAC now, since the pref should not control intranet behavior. We have no intranet counterpart. See further next follow-up. Test plan: Run t/db_dependent/XSLT.t Signed-off-by: Marcel de Rooy --- C4/XSLT.pm | 2 ++ t/db_dependent/XSLT.t | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 t/db_dependent/XSLT.t diff --git a/C4/XSLT.pm b/C4/XSLT.pm index d17a3b9894..cbbfb6cd40 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -377,6 +377,8 @@ sub engine { sub CustomXSLTExportList { my $opac = shift; # opac (1) vs intranet (0) + return [] if $opac && C4::Context->preference('OpacExportOptions') !~ /custom/; + my @tabFiles; my $dir = C4::Context->config( $opac ? 'opachtdocs' : 'intrahtdocs') . diff --git a/t/db_dependent/XSLT.t b/t/db_dependent/XSLT.t new file mode 100644 index 0000000000..5f91cdb44b --- /dev/null +++ b/t/db_dependent/XSLT.t @@ -0,0 +1,23 @@ +use Modern::Perl; +use Test::More tests => 1; + +use t::lib::Mocks; +use C4::XSLT; +use Koha::Database; + +our $schema = Koha::Database->new->schema; + +# Here we go +$schema->storage->txn_begin; +subtest 'CustomXSLTExportList: Check export options' => sub { + plan tests => 2; + t::lib::Mocks::mock_preference('OpacExportOptions', 'custom'); + + my $list = C4::XSLT::CustomXSLTExportList(1); + is( @$list>0, 1, 'We expect at least one result: simple export' ); + + t::lib::Mocks::mock_preference('OpacExportOptions', 'dc'); + $list = C4::XSLT::CustomXSLTExportList(1); + is( @$list, 0, 'We expect an empty list now' ); +}; +$schema->storage->txn_rollback; -- 2.11.0