From 10fd8c170af9da9d1f091f78468a3e934bae4e23 Mon Sep 17 00:00:00 2001 From: Max Kanat-Alexander Date: Sat, 13 Mar 2010 16:35:31 -0800 Subject: [PATCH] Bug 498309: Speed up show_bug when there are many comments by caching the 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 | 25 ++++++++++++++++--- .../en/default/bug/format_comment.txt.tmpl | 5 ++-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index c725dec56e..c5f6b65b09 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -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 = ""; $post = ""; } elsif (!is_open_state($bug_state)) { $pre = ''; - $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 = ''; } if (Bugzilla->user->can_see_bug($bug_num)) { diff --git a/template/en/default/bug/format_comment.txt.tmpl b/template/en/default/bug/format_comment.txt.tmpl index d53ec44c51..2e482ededa 100644 --- a/template/en/default/bug/format_comment.txt.tmpl +++ b/template/en/default/bug/format_comment.txt.tmpl @@ -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 %] -- 2.47.2