Bugzilla – Attachment 32764 Details for
Bug 13053
Do not use template cache when from commandline
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13053 - Do not use template cache when from commandline
Bug-13053---Do-not-use-template-cache-when-from-co.patch (text/plain), 2.88 KB, created by
Chris Cormack
on 2014-10-26 06:15:21 UTC
(
hide
)
Description:
Bug 13053 - Do not use template cache when from commandline
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2014-10-26 06:15:21 UTC
Size:
2.88 KB
patch
obsolete
>From 0d8647eaef2d72c1da8498b9d2afce3c7306081a Mon Sep 17 00:00:00 2001 >From: Fridolin Somers <fridolin.somers@biblibre.com> >Date: Thu, 9 Oct 2014 16:10:24 +0200 >Subject: [PATCH] Bug 13053 - Do not use template cache when from commandline > >You may define in config a folder (usually /tmp) for TT cache : >template_cache_dir in etc/koha-conf.xml. > >Some perl pages may be launched from commandline, like tools/export.pl. >Also, the script gather_print_notices.pl uses C4::Templates. > >The problem is that when script is launched from Apache, the Unix owner of cache files will be www-data. When script is launched from commandline, like in a cronjob, the Unix owner will be different (like a user named "koha"), causing a crash because cache files can only be read by its owner. > >This script disables the template cache if perl script is called from commandline. This cache is certainly only useful for web access. >Using GATEWAY_INTERFACE env var comes from tools/export.pl > >Test plan : >- Use a dev install of koha installed in a user home, ie "/home/kohadev" >- Define a folder for template_cache_dir in etc/koha-conf.xml. For example : <template_cache_dir>/tmp</template_cache_dir> >- Check there is no cached templates already in this forder >- Create a file "bib.list" containing a few existing biblionumbers >- As user kohadev, launch : tools/export.pl --record-type=bibs --id_list_file=bib.list >- Look at cache folder >=> Without patch you see cache files owned by user kohadev >=> With patch there are no cache files >- Use the Koha interfaces OPAC and Intranet >=> Without patch you get an error : Template process failed: file error - cache failed to write ... >=> With patch you have no error and cache files are generated with Apache user as owner > >Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> >--- > C4/Templates.pm | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > >diff --git a/C4/Templates.pm b/C4/Templates.pm >index 6a9d48b..ae1c878 100644 >--- a/C4/Templates.pm >+++ b/C4/Templates.pm >@@ -59,12 +59,14 @@ sub new { > push @includes, "$htdocs/$_/$lang/includes"; > push @includes, "$htdocs/$_/en/includes" unless $lang eq 'en'; > } >+ # Do not use template cache if script is called from commandline >+ my $use_template_cache = C4::Context->config('template_cache_dir') && defined $ENV{GATEWAY_INTERFACE}; > my $template = Template->new( > { EVAL_PERL => 1, > ABSOLUTE => 1, > PLUGIN_BASE => 'Koha::Template::Plugin', >- COMPILE_EXT => C4::Context->config('template_cache_dir')?'.ttc':'', >- COMPILE_DIR => C4::Context->config('template_cache_dir')?C4::Context->config('template_cache_dir'):'',, >+ COMPILE_EXT => $use_template_cache ? '.ttc' : '', >+ COMPILE_DIR => $use_template_cache ? C4::Context->config('template_cache_dir') : '', > INCLUDE_PATH => \@includes, > FILTERS => {}, > } >-- >2.1.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 13053
:
32089
|
32764
|
32767