Commit 2c8ad01e authored by jocuri%softhome.net's avatar jocuri%softhome.net

Patch for bug 277013: provides a fix for the SQL error that appears when a…

Patch for bug 277013: provides a fix for the SQL error that appears when a user's vote confirms a bug; patch by Frédéric Buclin <LpSolit@netscape.net>, r=wurblzap, a=justdave.
parent 24871f00
...@@ -250,6 +250,7 @@ sub CheckIfVotedConfirmed { ...@@ -250,6 +250,7 @@ sub CheckIfVotedConfirmed {
"FROM bugs, products " . "FROM bugs, products " .
"WHERE bugs.bug_id = $id AND products.id = bugs.product_id"); "WHERE bugs.bug_id = $id AND products.id = bugs.product_id");
my ($votes, $status, $votestoconfirm, $everconfirmed) = (FetchSQLData()); my ($votes, $status, $votestoconfirm, $everconfirmed) = (FetchSQLData());
my $ret = 0;
if ($votes >= $votestoconfirm && $status eq $::unconfirmedstate) { if ($votes >= $votestoconfirm && $status eq $::unconfirmedstate) {
SendSQL("UPDATE bugs SET bug_status = 'NEW', everconfirmed = 1 " . SendSQL("UPDATE bugs SET bug_status = 'NEW', everconfirmed = 1 " .
"WHERE bug_id = $id"); "WHERE bug_id = $id");
...@@ -273,9 +274,10 @@ sub CheckIfVotedConfirmed { ...@@ -273,9 +274,10 @@ sub CheckIfVotedConfirmed {
$template->process("bug/process/results.html.tmpl", $vars) $template->process("bug/process/results.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
$ret = 1;
} }
PopGlobalSQLState(); PopGlobalSQLState();
return $ret;
} }
sub LogActivityEntry { sub LogActivityEntry {
my ($i,$col,$removed,$added,$whoid,$timestamp) = @_; my ($i,$col,$removed,$added,$whoid,$timestamp) = @_;
......
...@@ -21,10 +21,12 @@ ...@@ -21,10 +21,12 @@
[% PROCESS global/variables.none.tmpl %] [% PROCESS global/variables.none.tmpl %]
[% h2 = voting_user.login FILTER html %] [% IF !header_done %]
[% PROCESS global/header.html.tmpl [% h2 = voting_user.login FILTER html %]
title = "Show Votes" [% PROCESS global/header.html.tmpl title = "Show Votes" %]
%] [% ELSE %]
<hr>
[% END %]
[% canedit = 1 IF voting_user.login == user.login %] [% canedit = 1 IF voting_user.login == user.login %]
......
...@@ -312,8 +312,12 @@ sub record_votes { ...@@ -312,8 +312,12 @@ sub record_votes {
# for products that only allow one vote per bug). In that case, we still # for products that only allow one vote per bug). In that case, we still
# need to clear the user's votes from the database. # need to clear the user's votes from the database.
my %affected; my %affected;
SendSQL("LOCK TABLES bugs write, votes write, products read, cc read, SendSQL("LOCK TABLES bugs WRITE, bugs_activity WRITE, votes WRITE,
fielddefs read, user_group_map read, bug_group_map read"); longdescs WRITE, profiles READ, products READ, components READ,
cc READ, dependencies READ, groups READ, fielddefs READ,
namedqueries READ, whine_queries READ, watch READ,
profiles AS watchers READ, profiles AS watched READ,
user_group_map READ, bug_group_map READ");
# Take note of, and delete the user's old votes from the database. # Take note of, and delete the user's old votes from the database.
SendSQL("SELECT bug_id FROM votes WHERE who = $who"); SendSQL("SELECT bug_id FROM votes WHERE who = $who");
...@@ -330,18 +334,18 @@ sub record_votes { ...@@ -330,18 +334,18 @@ sub record_votes {
SendSQL("INSERT INTO votes (who, bug_id, vote_count) SendSQL("INSERT INTO votes (who, bug_id, vote_count)
VALUES ($who, $id, ".$votes{$id}.")"); VALUES ($who, $id, ".$votes{$id}.")");
} }
$affected{$id} = 1; $affected{$id} = 1;
} }
# Update the cached values in the bugs table # Update the cached values in the bugs table
print $cgi->header();
foreach my $id (keys %affected) { foreach my $id (keys %affected) {
SendSQL("SELECT sum(vote_count) FROM votes WHERE bug_id = $id"); SendSQL("SELECT sum(vote_count) FROM votes WHERE bug_id = $id");
my $v = FetchOneColumn(); my $v = FetchOneColumn() || 0;
$v ||= 0;
SendSQL("UPDATE bugs SET votes = $v, delta_ts=delta_ts SendSQL("UPDATE bugs SET votes = $v, delta_ts=delta_ts
WHERE bug_id = $id"); WHERE bug_id = $id");
CheckIfVotedConfirmed($id, $who); my $confirmed = CheckIfVotedConfirmed($id, $who);
$vars->{'header_done'} = 1 if $confirmed;
} }
SendSQL("UNLOCK TABLES"); SendSQL("UNLOCK TABLES");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment