]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 304417: Template precompilation is clumsy when it comes to additional language...
authorwurblzap%gmail.com <>
Sun, 20 Nov 2005 08:00:42 +0000 (08:00 +0000)
committerwurblzap%gmail.com <>
Sun, 20 Nov 2005 08:00:42 +0000 (08:00 +0000)
Patch by Jochen Wiedmann <jochen.wiedmann@gmail.com>,
r=wurblzap, a=myk

Bugzilla/Template.pm
checksetup.pl

index 84231f6a14c7d125a697c17ff48f86dcefdbae69..44e236c8e63abc01cff493be4f9730d21d7d0f7a 100644 (file)
@@ -284,6 +284,13 @@ sub create {
             # Prevents line break on hyphens and whitespaces.
             no_break => sub {
                 my ($var) = @_;
+    my %opts = @_;
+    if ($opts{'clean_cache'}) {
+        # checksetup.pl will call us once for any template/lang directory.
+        # We need a possibility to reset the cache, so that no files from
+        # the previous language pollute the action.
+        $template_include_path = undef;
+    }
                 $var =~ s/ /\&nbsp;/g;
                 $var =~ s/-/\&#8209;/g;
                 return $var;
index 2302e5110ec119fbba4f38f5bfbb9d1e62675d91..d5fe6b4ee09770940b16edbbb18258e355cbeb5e 100755 (executable)
@@ -1197,27 +1197,6 @@ unless ($switch{'no_templates'}) {
        }
     }
 
-    # Search for template directories
-    # We include the default and custom directories separately to make
-    # sure we compile all templates
-    my @templatepaths = ();
-    {
-        use File::Spec; 
-        opendir(DIR, $templatedir) || die "Can't open '$templatedir': $!";
-        my @files = grep { /^[a-z-]+$/i } readdir(DIR);
-        closedir DIR;
-
-        foreach my $dir (@files) {
-            next if($dir =~ /^CVS$/i);
-            my $path = File::Spec->catdir($templatedir, $dir, 'custom');
-            push(@templatepaths, $path) if(-d $path);
-            $path = File::Spec->catdir($templatedir, $dir, 'extension');
-            push(@templatepaths, $path) if(-d $path);
-            $path = File::Spec->catdir($templatedir, $dir, 'default');
-            push(@templatepaths, $path) if(-d $path);
-        }
-    }
-
     # Precompile stuff. This speeds up initial access (so the template isn't
     # compiled multiple times simultaneously by different servers), and helps
     # to get the permissions right.
@@ -1244,12 +1223,25 @@ unless ($switch{'no_templates'}) {
         
         # Don't hang on templates which use the CGI library
         eval("use CGI qw(-no_debug)");
-        $::template = Bugzilla::Template->create();
+        
+        use File::Spec; 
+        opendir(DIR, $templatedir) || die "Can't open '$templatedir': $!";
+        my @files = grep { /^[a-z-]+$/i } readdir(DIR);
+        closedir DIR;
 
-        foreach $::templatepath (@templatepaths) {
-           # Traverse the template hierarchy. 
-           find({ wanted => \&compile, no_chdir => 1 }, $::templatepath);
-       }
+        foreach my $dir (@files) {
+            next if($dir =~ /^CVS$/i);
+            local $ENV{'HTTP_ACCEPT_LANGUAGE'} = $dir;
+            SetParam("languages", "$dir,en");
+            $::template = Bugzilla::Template->create(clean_cache => 1);
+            my @templatepaths;
+            foreach my $subdir (qw(custom extension default)) {
+                $::templatepath = File::Spec->catdir($templatedir, $dir, $subdir);
+                next unless -d $::templatepath;
+                # Traverse the template hierarchy. 
+                find({ wanted => \&compile, no_chdir => 1 }, $::templatepath);
+            }
+        }
     }
 }