]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 498309: Speed up show_bug when there are many comments by caching the
authorMax Kanat-Alexander <mkanat@bugzilla.org>
Sun, 14 Mar 2010 00:35:31 +0000 (16:35 -0800)
committerMax Kanat-Alexander <mkanat@bugzilla.org>
Sun, 14 Mar 2010 00:35:31 +0000 (16:35 -0800)
results of get_text calls in Bugzilla::Template, and removing the call
to field-descs.none.tmpl from format_comment.txt.tmpl.
r=LpSolit, a=LpSolit

Bugzilla/Template.pm
template/en/default/bug/format_comment.txt.tmpl

index c725dec56e1824c7aef0332fa8664479d1fff60a..c5f6b65b097a8816942b7801f6d083580e68f7f8 100644 (file)
@@ -213,11 +213,19 @@ sub quoteUrls {
     # Current bug ID this comment belongs to
     my $current_bugurl = $curr_bugid ? "show_bug.cgi?id=$curr_bugid" : "";
 
+    # This is a hack to speed up displaying comments for the Bugzilla 3.4
+    # branch.
+    my $word_cache = Bugzilla->request_cache->{template_get_text} ||= {};
+    Bugzilla->template_inner; # populates request_cache->{language}
+    my $lang = Bugzilla->request_cache->{language} || '';
+    my $bug_word = $word_cache->{$lang}->{bug} 
+                   ||= get_text('term', { term => 'bug' });
+
     # This handles bug a, comment b type stuff. Because we're using /g
     # we have to do this in one pattern, and so this is semi-messy.
     # Also, we can't use $bug_re?$comment_re? because that will match the
     # empty string
-    my $bug_word = get_text('term', { term => 'bug' });
+
     my $bug_re = qr/\Q$bug_word\E\s*\#?\s*(\d+)/i;
     my $comment_re = qr/comment\s*\#?\s*(\d+)/i;
     $text =~ s~\b($bug_re(?:\s*,?\s*$comment_re)?|$comment_re)
@@ -302,19 +310,30 @@ sub get_bug_link {
                                FROM bugs WHERE bugs.bug_id = ?',
                                undef, $bug_num);
 
+    # This is a hack to speed up displaying comments for the Bugzilla 3.4
+    # branch.
+    my $word_cache = Bugzilla->request_cache->{template_get_text} ||= {};
+    Bugzilla->template_inner; # populates request_cache->{language}
+    my $lang = Bugzilla->request_cache->{language} || '';
+
     if ($bug_state) {
         # Initialize these variables to be "" so that we don't get warnings
         # if we don't change them below (which is highly likely).
         my ($pre, $title, $post) = ("", "", "");
 
-        $title = get_text('get_status', {status => $bug_state});
+        my $status = $word_cache->{$lang}->{status}->{$bug_state} 
+                     ||= get_text('get_status', {status => $bug_state});
+        $title = $status;
         if ($bug_state eq 'UNCONFIRMED') {
             $pre = "<i>";
             $post = "</i>";
         }
         elsif (!is_open_state($bug_state)) {
             $pre = '<span class="bz_closed">';
-            $title .= ' ' . get_text('get_resolution', {resolution => $bug_res});
+            my $resolution = $word_cache->{$lang}->{resolution}->{$bug_res}
+                             ||= get_text('get_resolution', 
+                                          { resolution => $bug_res });
+            $title .= ' ' . $resolution;
             $post = '</span>';
         }
         if (Bugzilla->user->can_see_bug($bug_num)) {
index d53ec44c516c1fb31dfc079e337c061e7ded1c8d..2e482ededa7b2b39e6df8d6c86a46c46317f4f8d 100644 (file)
@@ -36,7 +36,7 @@
   #              already_wrapped: Determines whether the comment is pre-wrapped
   #%]
 
-[% PROCESS 'global/field-descs.none.tmpl' %]
+[% PROCESS 'global/variables.none.tmpl' %]
 
 [%- IF comment.type == constants.CMT_DUPE_OF -%]
 X[% comment.body %]
@@ -52,8 +52,7 @@ X[% comment.body %]
 [%+ terms.Bug %] moved to [% Param("move-to-url") %].
 If the move succeeded, [% comment.extra_data %] will receive a mail containing
 the number of the new [% terms.bug %] in the other database.
-If all went well, please mark this [% terms.bug %]
-[%+ get_status('VERIFIED') %], and paste in a link to the new [% terms.bug %].
+If all went well, please paste in a link to the new [% terms.bug %].
 Otherwise, reopen this [% terms.bug %].
 [%- ELSE -%]
 X[%- comment.body %]