From 8d97865049b228736912bbf64620987484bf697a Mon Sep 17 00:00:00 2001 From: "bbaetz%student.usyd.edu.au" <> Date: Sat, 27 Apr 2002 09:16:28 +0000 Subject: Bug 97832 - turn on template compilation. This means that the minimum TT version is now 2.07. r=myk, gerv --- checksetup.pl | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 101 insertions(+), 15 deletions(-) (limited to 'checksetup.pl') diff --git a/checksetup.pl b/checksetup.pl index 8df823614..336bc4d5b 100755 --- a/checksetup.pl +++ b/checksetup.pl @@ -181,7 +181,7 @@ unless (have_vers("Data::Dumper",0)) { push @missing,"Data::Dumper" } unless (have_vers("DBD::mysql","1.2209")) { push @missing,"DBD::mysql" } unless (have_vers("Date::Parse",0)) { push @missing,"Date::Parse" } unless (have_vers("AppConfig","1.52")) { push @missing,"AppConfig" } -unless (have_vers("Template","2.06")) { push @missing,"Template" } +unless (have_vers("Template","2.07")) { push @missing,"Template" } unless (have_vers("Text::Wrap","2001.0131")) { push @missing,"Text::Wrap" } unless (have_vers("File::Spec", "0.82")) { push @missing,"File::Spec" } @@ -525,6 +525,20 @@ my @my_priorities = @{*{$main::{'priorities'}}{ARRAY}}; my @my_platforms = @{*{$main::{'platforms'}}{ARRAY}}; my @my_opsys = @{*{$main::{'opsys'}}{ARRAY}}; +if ($my_webservergroup && ($< != 0)) { # zach: if not root, yell at them, bug 87398 + print <= $lastTemplateParamChange) { + # If File::Path::rmtree reported errors, then I'd use that + use File::Find; + sub remove { + return if $_ eq "."; + if (-d $_) { + rmdir $_ || die "Couldn't rmdir $_: $!\n"; + } else { + unlink $_ || die "Couldn't unlink $_: $!\n"; + } + } + finddepth(\&remove, 'data/template'); + } + } + + # Precompile stuff. This speeds up initial access (so the template isn't + # compiled multiple times simulataneously by different servers), and helps + # to get the permissions right. + eval("use Template"); + my $redir = ($^O =~ /MSWin32/i) ? "NUL" : "/dev/null"; + my $template = Template->new( + { + # Output to /dev/null here + OUTPUT => $redir, + + # Colon-separated list of directories containing templates. + INCLUDE_PATH => "template/en/custom:template/en/default", + + PRE_CHOMP => 1 , + TRIM => 1 , + + COMPILE_DIR => "data", # becomes data/template/en/{custom,default} + + # These don't actually need to do anything here, just exist + FILTERS => + { + strike => sub { return $_; } , + js => sub { return $_; }, + html => sub { return $_; }, + url_quote => sub { return $_; } + }, + }) || die ("Could not create Template: " . Template->error() . "\n"); + + sub compile { + return if (-d $_); + return if ($_ !~ /\.tmpl$/); + s!template/en/default/!!; # trim the bit we don't pass to TT + + $template->process($_, {}) + || die "Could not compile $_:" . $template->error() . "\n"; + } + + { + use File::Find; + + # Disable warnings which come from running the compiled templates + # This way is OK, because they're all runtime warnings. + # The reason we get these warnings here is that none of the required + # vars will be present. + local ($^W) = 0; + + # Traverse the default hierachy. Custom templates will be picked up + # via the INCLUDE_PATH, but we know that bugzilla will only be + # calling stuff which exists in en/default + # FIXME - if we start doing dynamic INCLUDE_PATH we may have to + # recurse all of template/, changing the INCLUDE_PATH each time + + find({wanted => \&compile, no_chdir => 1}, "template/en/default"); + } + # update the time on the stamp file + open FILE, '>data/template/.lastRebuild'; close FILE; + utime $lastTemplateParamChange, $lastTemplateParamChange, ('data/template/.lastRebuild'); +} # Just to be sure ... unlink "data/versioncache"; @@ -852,20 +950,6 @@ sub fixPerms { } if ($my_webservergroup) { - unless ($< == 0) { # zach: if not root, yell at them, bug 87398 - print <