summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Template.pm
diff options
context:
space:
mode:
authorMax Kanat-Alexander <mkanat@bugzilla.org>2010-10-14 01:36:18 +0200
committerMax Kanat-Alexander <mkanat@bugzilla.org>2010-10-14 01:36:18 +0200
commitf2d5af261b95310c2fb7d0565222c211998bff4f (patch)
tree08895bd9f38f0afbc549b2e70daaf78a28e1f9c2 /Bugzilla/Template.pm
parent8cfb548a7897269668cc5879025546e4ae8ac500 (diff)
downloadbugzilla-f2d5af261b95310c2fb7d0565222c211998bff4f.tar.gz
bugzilla-f2d5af261b95310c2fb7d0565222c211998bff4f.tar.xz
Bug 602418: Add "template_cache" to bz_locations(), a way of specifying that
cached templates should be stored somewhere else than the data directory. r=LpSolit, a=mkanat
Diffstat (limited to 'Bugzilla/Template.pm')
-rw-r--r--Bugzilla/Template.pm24
1 files changed, 14 insertions, 10 deletions
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm
index ee4d6cba2..46a4b6b72 100644
--- a/Bugzilla/Template.pm
+++ b/Bugzilla/Template.pm
@@ -633,7 +633,7 @@ sub create {
ABSOLUTE => 1,
RELATIVE => $ENV{MOD_PERL} ? 0 : 1,
- COMPILE_DIR => bz_locations()->{'datadir'} . "/template",
+ COMPILE_DIR => bz_locations()->{'template_cache'},
# Initialize templates (f.e. by loading plugins like Hook).
PRE_PROCESS => ["global/initialize.none.tmpl"],
@@ -990,23 +990,27 @@ sub precompile_templates {
my ($output) = @_;
# Remove the compiled templates.
+ my $cache_dir = bz_locations()->{'template_cache'};
my $datadir = bz_locations()->{'datadir'};
- if (-e "$datadir/template") {
+ if (-e $cache_dir) {
print install_string('template_removing_dir') . "\n" if $output;
# This frequently fails if the webserver made the files, because
# then the webserver owns the directories.
- rmtree("$datadir/template");
+ rmtree($cache_dir);
# Check that the directory was really removed, and if not, move it
# into data/deleteme/.
- if (-e "$datadir/template") {
+ if (-e $cache_dir) {
+ my $deleteme = "$datadir/deleteme";
+
print STDERR "\n\n",
install_string('template_removal_failed',
- { datadir => $datadir }), "\n\n";
- mkpath("$datadir/deleteme");
+ { deleteme => $deleteme,
+ template_cache => $cache_dir }), "\n\n";
+ mkpath($deleteme);
my $random = generate_random_password();
- rename("$datadir/template", "$datadir/deleteme/$random")
+ rename($cache_dir, "$deleteme/$random")
or die "move failed: $!";
}
}
@@ -1071,10 +1075,10 @@ sub _do_template_symlink {
my $abs_root = dirname($abs_path);
my $dir_name = basename($abs_path);
- my $datadir = bz_locations()->{'datadir'};
- my $container = "$datadir/template$abs_root";
+ my $cache_dir = bz_locations()->{'template_cache'};
+ my $container = "$cache_dir$abs_root";
mkpath($container);
- my $target = "$datadir/template/$dir_name";
+ my $target = "$cache_dir/$dir_name";
# Check if the directory exists, because if there are no extensions,
# there won't be an "data/template/extensions" directory to link to.
if (-d $target) {