summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorMax Kanat-Alexander <mkanat@bugzilla.org>2011-01-04 03:09:42 +0100
committerMax Kanat-Alexander <mkanat@bugzilla.org>2011-01-04 03:09:42 +0100
commitb6d1cc32f75d47437e382caccfccc5b2d98af765 (patch)
tree2ceff059de13f820287c0a84f248d55ef5630aff /Bugzilla
parenta1fa8d5f9f196d8611c64c1625e8269c9df52214 (diff)
downloadbugzilla-b6d1cc32f75d47437e382caccfccc5b2d98af765.tar.gz
bugzilla-b6d1cc32f75d47437e382caccfccc5b2d98af765.tar.xz
Bug 595410: Make it faster to display a bug that has a lot of dependencies.
r=LpSolit, a=LpSolit
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Bug.pm43
-rw-r--r--Bugzilla/Template.pm53
-rw-r--r--Bugzilla/Util.pm9
3 files changed, 64 insertions, 41 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index f3a28658a..398843009 100644
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -472,6 +472,26 @@ sub match {
return $class->SUPER::match(@_);
}
+# Helps load up information for bugs for show_bug.cgi and other situations
+# that will need to access info on lots of bugs.
+sub preload {
+ my ($class, $bugs) = @_;
+ my $user = Bugzilla->user;
+
+ # It would be faster but MUCH more complicated to select all the
+ # deps for the entire list in one SQL statement. If we ever have
+ # a profile that proves that that's necessary, we can switch over
+ # to the more complex method.
+ my @all_dep_ids;
+ foreach my $bug (@$bugs) {
+ push(@all_dep_ids, @{ $bug->blocked }, @{ $bug->dependson });
+ }
+ @all_dep_ids = uniq @all_dep_ids;
+ # If we don't do this, can_see_bug will do one call per bug in
+ # the dependency lists, during get_bug_link in Bugzilla::Template.
+ $user->visible_bugs(\@all_dep_ids);
+}
+
sub possible_duplicates {
my ($class, $params) = @_;
my $short_desc = $params->{summary};
@@ -2302,6 +2322,8 @@ sub set_dependencies {
detaint_natural($_) foreach (@$dependson, @$blocked);
$self->{'dependson'} = $dependson;
$self->{'blocked'} = $blocked;
+ delete $self->{depends_on_obj};
+ delete $self->{blocks_obj};
}
sub _clear_dup_id { $_[0]->{dup_id} = undef; }
sub set_dup_id {
@@ -3003,6 +3025,12 @@ sub blocked {
return $self->{'blocked'};
}
+sub blocks_obj {
+ my ($self) = @_;
+ $self->{blocks_obj} ||= $self->_bugs_in_order($self->blocked);
+ return $self->{blocks_obj};
+}
+
sub bug_group {
my ($self) = @_;
return join(', ', (map { $_->name } @{$self->groups_in}));
@@ -3096,6 +3124,12 @@ sub dependson {
return $self->{'dependson'};
}
+sub depends_on_obj {
+ my ($self) = @_;
+ $self->{depends_on_obj} ||= $self->_bugs_in_order($self->dependson);
+ return $self->{depends_on_obj};
+}
+
sub flag_types {
my ($self) = @_;
return $self->{'flag_types'} if exists $self->{'flag_types'};
@@ -3496,6 +3530,15 @@ sub EmitDependList {
return $list_ref;
}
+# Creates a lot of bug objects in the same order as the input array.
+sub _bugs_in_order {
+ my ($self, $bug_ids) = @_;
+ my $bugs = $self->new_from_list($bug_ids);
+ my %bug_map = map { $_->id => $_ } @$bugs;
+ my @result = map { $bug_map{$_} } @$bug_ids;
+ return \@result;
+}
+
# Get the activity of a bug, starting from $starttime (if given).
# This routine assumes Bugzilla::Bug->check has been previously called.
sub GetBugActivity {
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm
index 45b61b0de..453ca5596 100644
--- a/Bugzilla/Template.pm
+++ b/Bugzilla/Template.pm
@@ -317,51 +317,19 @@ sub get_attachment_link {
sub get_bug_link {
my ($bug, $link_text, $options) = @_;
+ $options ||= {};
my $dbh = Bugzilla->dbh;
- if (!$bug) {
- return html_quote('<missing bug number>');
+ if (defined $bug) {
+ $bug = blessed($bug) ? $bug : new Bugzilla::Bug($bug);
+ return $link_text if $bug->{error};
}
- $bug = blessed($bug) ? $bug : new Bugzilla::Bug($bug);
- return $link_text if $bug->{error};
-
- # 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) = ("", "", "");
- my @css_classes = ("bz_bug_link");
-
- $title = get_text('get_status', { status => $bug->bug_status });
-
- push @css_classes, "bz_status_" . css_class_quote($bug->bug_status);
-
- if ($bug->resolution) {
- push @css_classes, "bz_closed";
- $title .= ' ' . get_text('get_resolution',
- { resolution => $bug->resolution });
- }
- if (Bugzilla->user->can_see_bug($bug)) {
- $title .= " - " . $bug->short_desc;
- if ($options->{use_alias} && $link_text =~ /^\d+$/ && $bug->alias) {
- $link_text = $bug->alias;
- }
- }
- # Prevent code injection in the title.
- $title = html_quote(clean_text($title));
- my $linkval = "show_bug.cgi?id=" . $bug->id;
-
- if ($options->{full_url}) {
- $linkval = correct_urlbase() . $linkval;
- }
-
- if (defined $options->{comment_num}) {
- $linkval .= "#c" . $options->{comment_num};
- }
-
- $pre = '<span class="' . join(" ", @css_classes) . '">';
- $post = '</span>';
-
- return qq{$pre<a href="$linkval" title="$title">$link_text</a>$post};
+ my $template = Bugzilla->template_inner;
+ my $linkified;
+ $template->process('bug/link.html.tmpl',
+ { bug => $bug, link_text => $link_text, %$options }, \$linkified);
+ return $linkified;
}
# We use this instead of format because format doesn't deal well with
@@ -948,6 +916,9 @@ sub create {
# it only once per-language no matter how many times
# $template->process() is called.
'field_descs' => sub { return template_var('field_descs') },
+ # This way we don't have to load field-descs.none.tmpl in
+ # many templates.
+ 'display_value' => \&Bugzilla::Util::display_value,
'install_string' => \&Bugzilla::Install::Util::install_string,
diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm
index 6f29a1201..457eb7d02 100644
--- a/Bugzilla/Util.pm
+++ b/Bugzilla/Util.pm
@@ -639,6 +639,15 @@ sub template_var {
return $vars{$name};
}
+sub display_value {
+ my ($field, $value) = @_;
+ my $value_descs = template_var('value_descs');
+ if (defined $value_descs->{$field}->{$value}) {
+ return $value_descs->{$field}->{$value};
+ }
+ return $value;
+}
+
sub disable_utf8 {
if (Bugzilla->params->{'utf8'}) {
binmode STDOUT, ':bytes'; # Turn off UTF8 encoding.