Skip to content

Commit 87d85de

Browse files
authored
Bug 1986495 - Optimize bug updates in Phabbugz by converting to a single update
1 parent fa013fc commit 87d85de

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

extensions/PhabBugz/lib/Feed.pm

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,6 @@ sub process_uplift_request_form_change {
465465
# Process an uplift request form change for the passed revision object.
466466
my ($revision, $bug) = @_;
467467

468-
my ($timestamp) = Bugzilla->dbh->selectrow_array('SELECT NOW()');
469468
my $phab_bot_user = Bugzilla::User->new({name => PHAB_AUTOMATION_USER});
470469

471470
INFO('Commenting the uplift form on the bug.');
@@ -478,7 +477,6 @@ sub process_uplift_request_form_change {
478477
'isprivate' => 0,
479478
};
480479
$bug->add_comment($comment_content, $comment_params);
481-
$bug->update($timestamp);
482480

483481
my $revision_phid = $revision->phid;
484482
INFO(
@@ -526,14 +524,11 @@ sub process_uplift_request_form_change {
526524
if ($revision->uplift_request->{'Needs manual QE test'}) {
527525
INFO('Needs manual QE test is set.');
528526

529-
# Reload the current bug object so we can call update again
530-
my $reloaded_bug = Bugzilla::Bug->new($bug->id);
531-
532527
my @old_flags;
533528
my @new_flags;
534529

535530
# Find the current `qe-verify` flag state if it exists.
536-
foreach my $flag (@{$reloaded_bug->flags}) {
531+
foreach my $flag (@{$bug->flags}) {
537532
# Ignore for all flags except `qe-verify`.
538533
next if $flag->name ne 'qe-verify';
539534
# Set the flag to `+`. If already '+', it will be non-change.
@@ -556,8 +551,7 @@ sub process_uplift_request_form_change {
556551
}
557552

558553
# Set the flags.
559-
$reloaded_bug->set_flags(\@old_flags, \@new_flags);
560-
$reloaded_bug->update($timestamp);
554+
$bug->set_flags(\@old_flags, \@new_flags);
561555
}
562556

563557
INFO("Finished processing uplift request form change for $revision_phid.");
@@ -601,15 +595,6 @@ sub process_revision_change {
601595
my $restore_prev_user = set_phab_user();
602596
my $bug = $revision->bug;
603597

604-
# Process uplift request form changes if the hash has changed since phab-bot last
605-
# saw it.
606-
if (has_uplift_request_form_changed($revision)) {
607-
process_uplift_request_form_change($revision, $bug);
608-
609-
# Return early if updating from a story change.
610-
return if is_uplift_request_form_story_change($story_text);
611-
}
612-
613598
# Check to make sure bug id is valid and author can see it
614599
if ($bug->{error}
615600
|| !$revision->author->bugzilla_user->can_see_bug($revision->bug_id))
@@ -630,6 +615,20 @@ sub process_revision_change {
630615
return;
631616
}
632617

618+
my ($timestamp) = Bugzilla->dbh->selectrow_array("SELECT NOW()");
619+
620+
# Process uplift request form changes if the hash has changed since phab-bot last
621+
# saw it.
622+
if (has_uplift_request_form_changed($revision)) {
623+
process_uplift_request_form_change($revision, $bug);
624+
625+
# Return early if updating from a story change.
626+
if (is_uplift_request_form_story_change($story_text)) {
627+
$bug->update($timestamp);
628+
return;
629+
}
630+
}
631+
633632
# REVISION SECURITY POLICY
634633

635634
# If bug is public then remove privacy policy
@@ -678,8 +677,6 @@ sub process_revision_change {
678677
$revision->set_subscribers($subscribers);
679678
}
680679

681-
my ($timestamp) = Bugzilla->dbh->selectrow_array("SELECT NOW()");
682-
683680
# Create new or retrieve current attachment
684681
INFO('Checking for revision attachment');
685682
my $attachment = create_revision_attachment($bug, $revision, $timestamp,

0 commit comments

Comments
 (0)