]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Patch for bug 277013: provides a fix for the SQL error that appears when a user's...
authorjocuri%softhome.net <>
Sun, 9 Jan 2005 02:24:52 +0000 (02:24 +0000)
committerjocuri%softhome.net <>
Sun, 9 Jan 2005 02:24:52 +0000 (02:24 +0000)
CGI.pl
template/en/default/bug/votes/list-for-user.html.tmpl
votes.cgi

diff --git a/CGI.pl b/CGI.pl
index 47a11f816c5a6ec4af0abc77525c1cd9981d2642..b96c5e948684723285c43e74524eece320fccc0e 100644 (file)
--- a/CGI.pl
+++ b/CGI.pl
@@ -250,6 +250,7 @@ sub CheckIfVotedConfirmed {
             "FROM bugs, products " .
             "WHERE bugs.bug_id = $id AND products.id = bugs.product_id");
     my ($votes, $status, $votestoconfirm, $everconfirmed) = (FetchSQLData());
+    my $ret = 0;
     if ($votes >= $votestoconfirm && $status eq $::unconfirmedstate) {
         SendSQL("UPDATE bugs SET bug_status = 'NEW', everconfirmed = 1 " .
                 "WHERE bug_id = $id");
@@ -273,9 +274,10 @@ sub CheckIfVotedConfirmed {
         
         $template->process("bug/process/results.html.tmpl", $vars)
           || ThrowTemplateError($template->error());
+        $ret = 1;
     }
     PopGlobalSQLState();
-
+    return $ret;
 }
 sub LogActivityEntry {
     my ($i,$col,$removed,$added,$whoid,$timestamp) = @_;
index 27551f19d2b5229994efeb8c557bdfc0a23fe160..9bb3a1dd63684cc440a5719a3d13c5f569a5b0e8 100644 (file)
 
 [% PROCESS global/variables.none.tmpl %]
 
-[% h2 = voting_user.login FILTER html %]
-[% PROCESS global/header.html.tmpl
-           title = "Show Votes"
- %]
+[% IF !header_done %]
+  [% h2 = voting_user.login FILTER html %]
+  [% PROCESS global/header.html.tmpl title = "Show Votes" %]
+[% ELSE %]
+  <hr>
+[% END %]
 
 [% canedit = 1 IF voting_user.login == user.login %]
 
index 0573040482c91403d404b44e8bcab181d387c59b..ff0833e5c39aea83915c0322c04f686e93e7a638 100755 (executable)
--- a/votes.cgi
+++ b/votes.cgi
@@ -313,8 +313,12 @@ sub record_votes {
     # for products that only allow one vote per bug).  In that case, we still
     # need to clear the user's votes from the database.
     my %affected;
-    SendSQL("LOCK TABLES bugs write, votes write, products read, cc read,
-             fielddefs read, user_group_map read, bug_group_map read");
+    SendSQL("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");
     
     # Take note of, and delete the user's old votes from the database.
     SendSQL("SELECT bug_id FROM votes WHERE who = $who");
@@ -331,18 +335,18 @@ sub record_votes {
             SendSQL("INSERT INTO votes (who, bug_id, vote_count) 
                      VALUES ($who, $id, ".$votes{$id}.")");
         }
-        
         $affected{$id} = 1;
     }
     
     # Update the cached values in the bugs table
+    print $cgi->header();
     foreach my $id (keys %affected) {
         SendSQL("SELECT sum(vote_count) FROM votes WHERE bug_id = $id");
-        my $v = FetchOneColumn();
-        $v ||= 0;
+        my $v = FetchOneColumn() || 0;
         SendSQL("UPDATE bugs SET votes = $v, delta_ts=delta_ts 
                  WHERE bug_id = $id");
-        CheckIfVotedConfirmed($id, $who);
+        my $confirmed = CheckIfVotedConfirmed($id, $who);
+        $vars->{'header_done'} = 1 if $confirmed;
     }
 
     SendSQL("UNLOCK TABLES");