summaryrefslogtreecommitdiffstats
path: root/process_bug.cgi
diff options
context:
space:
mode:
Diffstat (limited to 'process_bug.cgi')
-rwxr-xr-xprocess_bug.cgi69
1 files changed, 57 insertions, 12 deletions
diff --git a/process_bug.cgi b/process_bug.cgi
index 9272dec60..b18398687 100755
--- a/process_bug.cgi
+++ b/process_bug.cgi
@@ -58,6 +58,7 @@ use Bugzilla::Keyword;
use Bugzilla::Flag;
use Bugzilla::Status;
use Bugzilla::Token;
+use Bugzilla::Instrument;
use List::MoreUtils qw(firstidx);
use Storable qw(dclone);
@@ -69,6 +70,8 @@ my $dbh = Bugzilla->dbh;
my $template = Bugzilla->template;
my $vars = {};
+my $timings = Bugzilla::Instrument->new('process_bug');
+
######################################################################
# Subroutines
######################################################################
@@ -93,6 +96,12 @@ sub should_set {
# Begin Data/Security Validation
######################################################################
+# BMO: Don't allow updating of bugs if disabled
+if (Bugzilla->params->{disable_bug_updates}) {
+ ThrowErrorPage('bug/process/updates-disabled.html.tmpl',
+ 'Bug updates are currently disabled.');
+}
+
# Create a list of objects for all bugs being modified in this request.
my @bug_objects;
if (defined $cgi->param('id')) {
@@ -136,6 +145,8 @@ Bugzilla::User::match_field({
print $cgi->header() unless Bugzilla->usage_mode == USAGE_MODE_EMAIL;
+$timings->time('load_bug');
+
# Check for a mid-air collision. Currently this only works when updating
# an individual bug.
if (defined $cgi->param('delta_ts'))
@@ -147,23 +158,43 @@ if (defined $cgi->param('delta_ts'))
Bugzilla::Bug::GetBugActivity($first_bug->id, undef,
scalar $cgi->param('delta_ts'));
- $vars->{'title_tag'} = "mid_air";
-
ThrowCodeError('undefined_field', { field => 'longdesclength' })
if !defined $cgi->param('longdesclength');
- $vars->{'start_at'} = $cgi->param('longdesclength');
+ my $start_at = $cgi->param('longdesclength');
+
# Always sort midair collision comments oldest to newest,
# regardless of the user's personal preference.
- $vars->{'comments'} = $first_bug->comments({ order => "oldest_to_newest" });
- $vars->{'bug'} = $first_bug;
+ my $comments = $first_bug->comments({ order => "oldest_to_newest" });
# The token contains the old delta_ts. We need a new one.
$cgi->param('token', issue_hash_token([$first_bug->id, $first_bug->delta_ts]));
- # Warn the user about the mid-air collision and ask them what to do.
- $template->process("bug/process/midair.html.tmpl", $vars)
- || ThrowTemplateError($template->error());
- exit;
+
+ # Show midair if previous changes made other than CC
+ # and/or one or more comments were made
+ my $do_midair = scalar @$comments > $start_at ? 1 : 0;
+
+ if (!$do_midair) {
+ foreach my $operation (@{ $vars->{'operations'} }) {
+ foreach my $change (@{ $operation->{'changes'} }) {
+ $do_midair = 1 if $change->{'fieldname'} ne 'cc';
+ last;
+ }
+ last if $do_midair;
+ }
+ }
+
+ if ($do_midair) {
+ $vars->{'title_tag'} = "mid_air";
+ $vars->{'start_at'} = $start_at;
+ $vars->{'comments'} = $comments;
+ $vars->{'bug'} = $first_bug;
+
+ # Warn the user about the mid-air collision and ask them what to do.
+ $template->process("bug/process/midair.html.tmpl", $vars)
+ || ThrowTemplateError($template->error());
+ exit;
+ }
}
}
@@ -179,6 +210,8 @@ else {
check_token_data($token, 'buglist_mass_change', 'query.cgi');
}
+$timings->time('mid_air');
+
######################################################################
# End Data/Security Validation
######################################################################
@@ -206,6 +239,7 @@ if (defined $cgi->param('id')) {
# Include both action = 'same_bug' and 'nothing'.
else {
$vars->{'bug'} = $first_bug;
+ $vars->{'bugids'} = $first_bug->id;
}
}
else {
@@ -230,9 +264,9 @@ my @set_fields = qw(op_sys rep_platform priority bug_severity
bug_file_loc status_whiteboard short_desc
deadline remaining_time estimated_time
work_time set_default_assignee set_default_qa_contact
- cclist_accessible reporter_accessible
+ cclist_accessible reporter_accessible
product confirm_product_change
- bug_status resolution dup_id);
+ bug_status resolution dup_id bug_ignored);
push(@set_fields, 'assigned_to') if !$cgi->param('set_default_assignee');
push(@set_fields, 'qa_contact') if !$cgi->param('set_default_qa_contact');
my %field_translation = (
@@ -366,11 +400,14 @@ if (defined $cgi->param('id')) {
$first_bug->set_flags($flags, $new_flags);
}
+$timings->time('update_time');
+
##############################
# Do Actual Database Updates #
##############################
foreach my $bug (@bug_objects) {
my $changes = $bug->update();
+ $timings->time('db_time');
if ($changes->{'bug_status'}) {
my $new_status = $changes->{'bug_status'}->[1];
@@ -382,7 +419,11 @@ foreach my $bug (@bug_objects) {
}
}
- $bug->send_changes($changes, $vars);
+ my $recipient_count = $bug->send_changes($changes, $vars);
+ $timings->time('bugmail_time');
+ $timings->label('bug-' . $bug->id);
+ $timings->label('user-' . $user->id);
+ $timings->value('recipient_count', $recipient_count);
}
# Delete the session token used for the mass-change.
@@ -408,6 +449,8 @@ elsif ($action eq 'next_bug' or $action eq 'same_bug') {
}
$template->process("bug/show.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
+ $timings->time('template_time');
+ $timings->log() if scalar(@bug_objects) == 1;
exit;
}
} elsif ($action ne 'nothing') {
@@ -420,6 +463,8 @@ unless (Bugzilla->usage_mode == USAGE_MODE_EMAIL) {
|| ThrowTemplateError($template->error());
$template->process("global/footer.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
+ $timings->time('template_time');
+ $timings->log() if scalar(@bug_objects) == 1;
}
1;