summaryrefslogtreecommitdiffstats
path: root/votes.cgi
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2005-08-23 21:17:16 +0200
committerlpsolit%gmail.com <>2005-08-23 21:17:16 +0200
commitc48c345eb62acb75a46db84f5d6ab53d164d01ef (patch)
treece3b13167cb1647aa23d15535678338d37ae795c /votes.cgi
parentec1a877642aca183d748e88a08a63f4568e3d357 (diff)
downloadbugzilla-c48c345eb62acb75a46db84f5d6ab53d164d01ef.tar.gz
bugzilla-c48c345eb62acb75a46db84f5d6ab53d164d01ef.tar.xz
Bug 303366: Possible locking tables conflict when voting for bugs - Patch by Frédéric Buclin <LpSolit@gmail.com> r=wurblzap a=justdave
Diffstat (limited to 'votes.cgi')
-rwxr-xr-xvotes.cgi37
1 files changed, 25 insertions, 12 deletions
diff --git a/votes.cgi b/votes.cgi
index 8d7e7cf63..13f1ec7e2 100755
--- a/votes.cgi
+++ b/votes.cgi
@@ -319,13 +319,8 @@ sub record_votes {
# need to clear the user's votes from the database.
my %affected;
$dbh->bz_lock_tables('bugs WRITE', 'bugs_activity WRITE',
- 'votes WRITE', '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',
- 'email_setting READ');
+ 'votes WRITE', 'longdescs WRITE',
+ 'products READ', 'fielddefs READ');
# Take note of, and delete the user's old votes from the database.
SendSQL("SELECT bug_id FROM votes WHERE who = $who");
@@ -347,15 +342,33 @@ sub record_votes {
# Update the cached values in the bugs table
print $cgi->header();
+ my @updated_bugs = ();
+
+ my $sth_getVotes = $dbh->prepare("SELECT SUM(vote_count) FROM votes
+ WHERE bug_id = ?");
+
+ my $sth_updateVotes = $dbh->prepare("UPDATE bugs SET votes = ?
+ WHERE bug_id = ?");
+
foreach my $id (keys %affected) {
- SendSQL("SELECT sum(vote_count) FROM votes WHERE bug_id = $id");
- my $v = FetchOneColumn() || 0;
- SendSQL("UPDATE bugs SET votes = $v WHERE bug_id = $id");
+ $sth_getVotes->execute($id);
+ my $v = $sth_getVotes->fetchrow_array || 0;
+ $sth_updateVotes->execute($v, $id);
+
my $confirmed = CheckIfVotedConfirmed($id, $who);
- $vars->{'header_done'} = 1 if $confirmed;
+ push (@updated_bugs, $id) if $confirmed;
}
-
$dbh->bz_unlock_tables();
+ $vars->{'type'} = "votes";
+ $vars->{'mailrecipients'} = { 'changer' => $who };
+
+ foreach my $bug_id (@updated_bugs) {
+ $vars->{'id'} = $bug_id;
+ $template->process("bug/process/results.html.tmpl", $vars)
+ || ThrowTemplateError($template->error());
+ # Set header_done to 1 only after the first bug.
+ $vars->{'header_done'} = 1;
+ }
$vars->{'votes_recorded'} = 1;
}