From: mkanat%bugzilla.org <> Date: Tue, 16 Oct 2007 15:16:34 +0000 (+0000) Subject: Bug 383522: mod_perl creates a separate template directory X-Git-Tag: bugzilla-3.0.3~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0f0ef3d384f7e91872847c8b126ee5232e76ddc8;p=thirdparty%2Fbugzilla.git Bug 383522: mod_perl creates a separate template directory Patch By Max Kanat-Alexander r=LpSolit, a=mkanat --- diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index c05500ede4..cf483bc7c6 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -42,10 +42,12 @@ use Bugzilla::Error; use MIME::Base64; use Bugzilla::Bug; +use Cwd qw(abs_path); # 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; @@ -898,6 +900,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}; }