From 527d3cb69e1f18ac3c3235ec1eb0016c431f7162 Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Mon, 15 May 2017 17:37:50 -0400 Subject: Bug 1361621 - chunk resolve_bug.pl bug updates into multiple transactions --- scripts/resolve_bugs.pl | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'scripts') diff --git a/scripts/resolve_bugs.pl b/scripts/resolve_bugs.pl index 5a9199d39..31f38aae8 100755 --- a/scripts/resolve_bugs.pl +++ b/scripts/resolve_bugs.pl @@ -19,7 +19,7 @@ use Bugzilla::Group; use Bugzilla::Search; use Getopt::Long; -my ($product, $comment); +my ($product, $component, $comment); my $resolution = 'WONTFIX'; Bugzilla->usage_mode(USAGE_MODE_CMDLINE); @@ -27,6 +27,7 @@ Bugzilla->usage_mode(USAGE_MODE_CMDLINE); GetOptions( 'product|p=s' => \$product, 'resolution|r=s' => \$resolution, + 'component|c=s' => \$component, 'comment|m=s' => \$comment, ); @@ -41,9 +42,12 @@ $auto_user->{groups} = [ Bugzilla::Group->get_all ]; $auto_user->{bless_groups} = [ Bugzilla::Group->get_all ]; Bugzilla->set_user($auto_user); +my $query = { resolution => '---', product => $product }; +$query->{component} = $component if defined $component; + my $search = Bugzilla::Search->new( fields => ['bug_id'], - params => { resolution => '---', product => $product }, + params => $query, ); my ($data) = $search->data; @@ -60,12 +64,13 @@ Press to stop or to continue... EOF getc(); -my $timestamp = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)'); - -$dbh->bz_start_transaction; foreach my $row (@$data) { my $bug_id = shift @$row; warn "Updating bug $bug_id\n"; + + my $timestamp = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)'); + + $dbh->bz_start_transaction; my $bug = Bugzilla::Bug->new($bug_id); $bug->set_bug_status('RESOLVED', { resolution => $resolution }); $bug->add_comment($comment); @@ -76,8 +81,9 @@ foreach my $row (@$data) { Bugzilla::Hook::process('request_cleanup'); Bugzilla::Bug->CLEANUP; Bugzilla->clear_request_cache(except => [qw(user dbh dbh_main dbh_shadow memcached)]); + + $dbh->bz_commit_transaction; } -$dbh->bz_commit_transaction; Bugzilla->memcached->clear_all(); -- cgit v1.2.3-24-g4f1b