summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2007-10-16 17:15:03 +0200
committermkanat%bugzilla.org <>2007-10-16 17:15:03 +0200
commit817f79e66410150a01637f2243a1b0dd69c8c5a4 (patch)
tree4f1e77a21f814df350c58efa728a97d371b81f42
parent67fd51bb4028941a5e6b10dd0199c96285a3aeef (diff)
downloadbugzilla-817f79e66410150a01637f2243a1b0dd69c8c5a4.tar.gz
bugzilla-817f79e66410150a01637f2243a1b0dd69c8c5a4.tar.xz
Bug 383522: mod_perl creates a separate template directory
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=mkanat
-rw-r--r--Bugzilla/Template.pm21
1 files changed, 20 insertions, 1 deletions
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm
index 0f08662e0..62334999d 100644
--- a/Bugzilla/Template.pm
+++ b/Bugzilla/Template.pm
@@ -42,11 +42,13 @@ use Bugzilla::User;
use Bugzilla::Error;
use Bugzilla::Status;
+use Cwd qw(abs_path);
use MIME::Base64;
# for time2str - replace by TT Date plugin??
use Date::Format ();
+use File::Basename qw(dirname);
use File::Find;
-use File::Path;
+use File::Path qw(rmtree mkpath);
use File::Spec;
use IO::Dir;
@@ -783,6 +785,23 @@ sub precompile_templates {
}
}
+ # Under mod_perl, we look for templates using the absolute path of the
+ # template directory, which causes Template Toolkit to look for their
+ # *compiled* versions using the full absolute path under the data/template
+ # directory. (Like data/template/var/www/html/mod_perl/.) To avoid
+ # re-compiling templates under mod_perl, we symlink to the
+ # already-compiled templates.
+ my $abs_root = dirname(abs_path($templatedir));
+ mkpath("$datadir/template$abs_root");
+ my $todir = "$datadir/template$abs_root";
+ # We use abs2rel so that the symlink will look like "../../../../template"
+ # which works, while just "data/template/template/" doesn't work.
+ my $fromdir = File::Spec->abs2rel("$datadir/template/template", $todir);
+ # We eval for systems (like Windows) that can't symlink, where "symlink"
+ # throws a fatal error.
+ eval { symlink($fromdir, "$todir/template")
+ or warn "Failed to symlink from $fromdir to $todir: $!" };
+
# If anything created a Template object before now, clear it out.
delete Bugzilla->request_cache->{template};
}