diff options
author | lpsolit%gmail.com <> | 2009-07-01 11:06:34 +0000 |
---|---|---|
committer | lpsolit%gmail.com <> | 2009-07-01 11:06:34 +0000 |
commit | ad9aee236ed94b276e99abe31ee919f38eed238d (patch) | |
tree | 2bc478351aa4a71ee75912a0bbbe323090fef638 | |
parent | Bug 498318: Speed up field-descs.none.tmpl (diff) | |
download | bugzilla-ad9aee236ed94b276e99abe31ee919f38eed238d.tar.gz bugzilla-ad9aee236ed94b276e99abe31ee919f38eed238d.tar.bz2 bugzilla-ad9aee236ed94b276e99abe31ee919f38eed238d.zip |
Bug 500900: Confirming bugs requires NEW state to exist - Patch by Frédéric Buclin <LpSolit@gmail.com> r/a=mkanat
-rw-r--r-- | Bugzilla/Bug.pm | 48 | ||||
-rwxr-xr-x | editproducts.cgi | 2 | ||||
-rwxr-xr-x | process_bug.cgi | 2 | ||||
-rw-r--r-- | template/en/default/global/code-error.html.tmpl | 7 | ||||
-rwxr-xr-x | votes.cgi | 2 |
5 files changed, 26 insertions, 35 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index 7f2b8d84b..3ede4732c 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -3142,45 +3142,31 @@ sub RemoveVotes { # If a user votes for a bug, or the number of votes required to # confirm a bug has been reduced, check if the bug is now confirmed. sub CheckIfVotedConfirmed { - my ($id, $who) = (@_); - my $dbh = Bugzilla->dbh; - - # XXX - Use bug methods to update the bug status and everconfirmed. + my $id = shift; my $bug = new Bugzilla::Bug($id); - my ($votes, $status, $everconfirmed, $votestoconfirm, $timestamp) = - $dbh->selectrow_array("SELECT votes, bug_status, everconfirmed, " . - " votestoconfirm, NOW() " . - "FROM bugs INNER JOIN products " . - " ON products.id = bugs.product_id " . - "WHERE bugs.bug_id = ?", - undef, $id); - my $ret = 0; - if ($votes >= $votestoconfirm && !$everconfirmed) { + if (!$bug->everconfirmed && $bug->votes >= $bug->product_obj->votes_to_confirm) { $bug->add_comment('', { type => CMT_POPULAR_VOTES }); - $bug->update(); - if ($status eq 'UNCONFIRMED') { - my $fieldid = get_field_id("bug_status"); - $dbh->do("UPDATE bugs SET bug_status = 'NEW', everconfirmed = 1, " . - "delta_ts = ? WHERE bug_id = ?", - undef, ($timestamp, $id)); - $dbh->do("INSERT INTO bugs_activity " . - "(bug_id, who, bug_when, fieldid, removed, added) " . - "VALUES (?, ?, ?, ?, ?, ?)", - undef, ($id, $who, $timestamp, $fieldid, 'UNCONFIRMED', 'NEW')); + if ($bug->bug_status eq 'UNCONFIRMED') { + # Get a valid open state. + my $new_status; + foreach my $state (@{$bug->status->can_change_to}) { + if ($state->is_open && $state->name ne 'UNCONFIRMED') { + $new_status = $state->name; + last; + } + } + ThrowCodeError('no_open_bug_status') unless $new_status; + + $bug->set_status($new_status); } else { - $dbh->do("UPDATE bugs SET everconfirmed = 1, delta_ts = ? " . - "WHERE bug_id = ?", undef, ($timestamp, $id)); + # If the bug is in a closed state, only set everconfirmed to 1. + $bug->_set_everconfirmed(1); } - - my $fieldid = get_field_id("everconfirmed"); - $dbh->do("INSERT INTO bugs_activity " . - "(bug_id, who, bug_when, fieldid, removed, added) " . - "VALUES (?, ?, ?, ?, ?, ?)", - undef, ($id, $who, $timestamp, $fieldid, '0', '1')); + $bug->update(); $ret = 1; } diff --git a/editproducts.cgi b/editproducts.cgi index cb451b065..b7171f3e7 100755 --- a/editproducts.cgi +++ b/editproducts.cgi @@ -1024,7 +1024,7 @@ if ($action eq 'update') { my @updated_bugs = (); foreach my $bug_id (@$bug_list) { - my $confirmed = CheckIfVotedConfirmed($bug_id, $whoid); + my $confirmed = CheckIfVotedConfirmed($bug_id); push (@updated_bugs, $bug_id) if $confirmed; } diff --git a/process_bug.cgi b/process_bug.cgi index f21b1724e..04fd14437 100755 --- a/process_bug.cgi +++ b/process_bug.cgi @@ -571,7 +571,7 @@ foreach my $bug (@bug_objects) { # a list of messages to send to voters. # We delay the sending of these messages till tables are unlocked. $msgs = RemoveVotes($bug->id, 0, 'votes_bug_moved'); - CheckIfVotedConfirmed($bug->id, Bugzilla->user->id); + CheckIfVotedConfirmed($bug->id); } # Set and update flags. diff --git a/template/en/default/global/code-error.html.tmpl b/template/en/default/global/code-error.html.tmpl index 80645a851..bb07068ec 100644 --- a/template/en/default/global/code-error.html.tmpl +++ b/template/en/default/global/code-error.html.tmpl @@ -32,7 +32,7 @@ # in this file; if you do not wish to change it, use the "none" filter. #%] -[% PROCESS global/variables.none.tmpl %] +[% PROCESS "global/field-descs.none.tmpl" %] [% DEFAULT title = "Internal Error" %] @@ -313,6 +313,11 @@ You cannot set the resolution of [% terms.abug %] to MOVED without moving the [% terms.bug %]. + [% ELSIF error == "no_open_bug_status" %] + [% title = "$terms.Bug Cannot Be Confirmed" %] + There is no valid transition from + [%+ get_status("UNCONFIRMED") FILTER html %] to an open state. + [% ELSIF error == "param_must_be_numeric" %] [% title = "Invalid Parameter" %] Invalid parameter passed to [% function FILTER html %]. @@ -336,7 +336,7 @@ sub record_votes { my $v = $sth_getVotes->fetchrow_array || 0; $sth_updateVotes->execute($v, $id); - my $confirmed = CheckIfVotedConfirmed($id, $who); + my $confirmed = CheckIfVotedConfirmed($id); push (@updated_bugs, $id) if $confirmed; } $dbh->bz_commit_transaction(); |