]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 180086 - Rename 'count' column in votes tables
authorbbaetz%acm.org <>
Sun, 27 Apr 2003 14:20:36 +0000 (14:20 +0000)
committerbbaetz%acm.org <>
Sun, 27 Apr 2003 14:20:36 +0000 (14:20 +0000)
patch by bugzilla@chimpychompy.org (GavinS)
r=bbaetz,justdave
a=justdave

Bug.pm
Bugzilla/Bug.pm
checksetup.pl
editproducts.cgi
globals.pl
sanitycheck.cgi
votes.cgi

diff --git a/Bug.pm b/Bug.pm
index 9e8e44c55bfbcbd7da31f65ada9d12218d2abff1..750fd818643af7d8c38c94e7fa941d3e62299821 100755 (executable)
--- a/Bug.pm
+++ b/Bug.pm
@@ -140,7 +140,7 @@ sub initBug  {
       reporter, bug_file_loc, short_desc, target_milestone,
       qa_contact, status_whiteboard,
       DATE_FORMAT(creation_ts,'%Y.%m.%d %H:%i'),
-      delta_ts, sum(votes.count),
+      delta_ts, sum(votes.vote_count),
       reporter_accessible, cclist_accessible,
       estimated_time, remaining_time
     from bugs left join votes using(bug_id),
index 9e8e44c55bfbcbd7da31f65ada9d12218d2abff1..750fd818643af7d8c38c94e7fa941d3e62299821 100755 (executable)
@@ -140,7 +140,7 @@ sub initBug  {
       reporter, bug_file_loc, short_desc, target_milestone,
       qa_contact, status_whiteboard,
       DATE_FORMAT(creation_ts,'%Y.%m.%d %H:%i'),
-      delta_ts, sum(votes.count),
+      delta_ts, sum(votes.vote_count),
       reporter_accessible, cclist_accessible,
       estimated_time, remaining_time
     from bugs left join votes using(bug_id),
index f3228e804c6e17d2b62870738c4787ef8c1df06e..d9c2ce04d3c3aeb3d83ce4181552255c6c29b465 100755 (executable)
@@ -1356,7 +1356,7 @@ print "\n" unless $silent;
 # safer than the make*.sh shell scripts used to be, because they won't
 # delete existing tables.
 #
-# If you want intentionally do this, yon can always drop a table and re-run
+# If you want to intentionally do this, you can always drop a table and re-run
 # checksetup, e.g. like this:
 #
 #    $ mysql bugs
@@ -1659,7 +1659,7 @@ $table{versions} =
 $table{votes} =
    'who mediumint not null,
     bug_id mediumint not null,
-    count smallint not null,
+    vote_count smallint not null,
 
     index(who),
     index(bug_id)';
@@ -3869,11 +3869,21 @@ if (TableExists('shadowlog')) {
     $dbh->do("DROP TABLE shadowlog");
 }
 
-# 2003-04-24 - myk@mozilla.org/bbaetz@acm.org, bug 201018
-# Force all cached groups to be updated at login, due to security
-# At the next schema change, this should be moved inside that block so that the
-# update doesn't happen on every run
-$dbh->do("UPDATE profiles SET refreshed_when='1900-01-01 00:00:00'");
+# 2003-04-XX - bugzilla@chimpychompy.org (GavinS)
+#
+# Bug 180086 (http://bugzilla.mozilla.org/show_bug.cgi?id=180086)
+#
+# Renaming the 'count' column in the votes table because Sybase doesn't
+# like it
+if (GetFieldDef('votes', 'count')) {
+    # 2003-04-24 - myk@mozilla.org/bbaetz@acm.org, bug 201018
+    # Force all cached groups to be updated at login, due to security bug
+    # Do this here, inside the next schema change block, so that it doesn't
+    # get invalidated on every checksetup run.
+    $dbh->do("UPDATE profiles SET refreshed_when='1900-01-01 00:00:00'");
+
+    RenameField ('votes', 'count', 'vote_count');
+}
 
 #
 # Final checks...
index 9592c02ad815b7627fe90e929e56dbb51214ae37..147fbbc38cc719569c4718a40deecfa7aaa69b59 100755 (executable)
@@ -1170,7 +1170,7 @@ if ($action eq 'update') {
                     "FROM votes, bugs " .
                     "WHERE bugs.bug_id = votes.bug_id " .
                     " AND bugs.product_id = $product_id " .
-                    " AND votes.count > $maxvotesperbug");
+                    " AND votes.vote_count > $maxvotesperbug");
             my @list;
             while (MoreSQLData()) {
                 my ($who, $id) = (FetchSQLData());
@@ -1183,7 +1183,7 @@ if ($action eq 'update') {
                 print qq{<br>Removed votes for bug <A HREF="show_bug.cgi?id=$id">$id</A> from $name\n};
             }
         }
-        SendSQL("SELECT votes.who, votes.count FROM votes, bugs " .
+        SendSQL("SELECT votes.who, votes.vote_count FROM votes, bugs " .
                 "WHERE bugs.bug_id = votes.bug_id " .
                 " AND bugs.product_id = $product_id");
         my %counts;
index 4caaa3f84306b01e3b50751ce2c2ff5d1a750c95..88c8720e88454be4d2039b10c3bc39f9c741b39c 100644 (file)
@@ -1355,7 +1355,7 @@ sub RemoveVotes {
     if ($who) {
         $whopart = " AND votes.who = $who";
     }
-    SendSQL("SELECT profiles.login_name, profiles.userid, votes.count, " .
+    SendSQL("SELECT profiles.login_name, profiles.userid, votes.vote_count, " .
             "products.votesperuser, products.maxvotesperbug " .
             "FROM profiles " . 
             "LEFT JOIN votes ON profiles.userid = votes.who " .
@@ -1393,7 +1393,7 @@ sub RemoveVotes {
 
             my $newvotestext;
             if ($newvotes) {
-                SendSQL("UPDATE votes SET count = $newvotes " .
+                SendSQL("UPDATE votes SET vote_count = $newvotes " .
                         "WHERE bug_id = $id AND who = $userid");
                 $s = $newvotes == 1 ? "" : "s";
                 $newvotestext = "You still have $newvotes vote$s on this bug."
@@ -1436,7 +1436,7 @@ sub RemoveVotes {
                 close SENDMAIL;
             }
         }
-        SendSQL("SELECT SUM(count) FROM votes WHERE bug_id = $id");
+        SendSQL("SELECT SUM(vote_count) FROM votes WHERE bug_id = $id");
         my $v = FetchOneColumn();
         $v ||= 0;
         SendSQL("UPDATE bugs SET votes = $v, delta_ts = delta_ts " .
index 16a12396782af4a2a2c1dabbb9c8e3de81d6f4b5..98734e5b07a122e63b0ae691d33f53f13c9a8689 100755 (executable)
@@ -82,7 +82,7 @@ if (exists $::FORM{'rebuildvotecache'}) {
     Status("OK, now rebuilding vote cache.");
     SendSQL("lock tables bugs write, votes read");
     SendSQL("update bugs set votes = 0, delta_ts=delta_ts");
-    SendSQL("select bug_id, sum(count) from votes group by bug_id");
+    SendSQL("select bug_id, sum(vote_count) from votes group by bug_id");
     my %votes;
     while (@row = FetchSQLData()) {
         my ($id, $v) = (@row);
@@ -433,7 +433,7 @@ while (@row = FetchSQLData()) {
 }
 
 Status("Checking cached vote counts");
-SendSQL("select bug_id, sum(count) from votes group by bug_id");
+SendSQL("select bug_id, sum(vote_count) from votes group by bug_id");
 
 while (@row = FetchSQLData()) {
     my ($id, $v) = (@row);
index 6b35fc0276651bca697862dd86ede76b138f9a51..e386d542221d1d28fee172939baf8f9cef48f1ef 100755 (executable)
--- a/votes.cgi
+++ b/votes.cgi
@@ -92,7 +92,7 @@ sub show_bug {
     my $total = 0;
     my @users;
     
-    SendSQL("SELECT profiles.login_name, votes.who, votes.count 
+    SendSQL("SELECT profiles.login_name, votes.who, votes.vote_count 
              FROM votes, profiles 
              WHERE votes.bug_id = $bug_id 
                AND profiles.userid = votes.who");
@@ -137,10 +137,10 @@ sub show_user {
     if ($canedit && $bug_id) {
         # Make sure there is an entry for this bug
         # in the vote table, just so that things display right.
-        SendSQL("SELECT votes.count FROM votes 
+        SendSQL("SELECT votes.vote_count FROM votes 
                  WHERE votes.bug_id = $bug_id AND votes.who = $who");
         if (!FetchOneColumn()) {
-            SendSQL("INSERT INTO votes (who, bug_id, count) 
+            SendSQL("INSERT INTO votes (who, bug_id, vote_count) 
                      VALUES ($who, $bug_id, 0)");
         }
     }
@@ -167,7 +167,7 @@ sub show_user {
         my $total = 0;
         my $onevoteonly = 0;
         
-        SendSQL("SELECT votes.bug_id, votes.count, bugs.short_desc,
+        SendSQL("SELECT votes.bug_id, votes.vote_count, bugs.short_desc,
                         bugs.bug_status 
                   FROM  votes, bugs, products
                   WHERE votes.who = $who 
@@ -207,7 +207,7 @@ sub show_user {
         }
     }
 
-    SendSQL("DELETE FROM votes WHERE count <= 0");
+    SendSQL("DELETE FROM votes WHERE vote_count <= 0");
     SendSQL("UNLOCK TABLES");
     
     $vars->{'voting_user'} = { "login" => $name };
@@ -318,7 +318,7 @@ sub record_votes {
     # Insert the new values in their place
     foreach my $id (@buglist) {
         if ($::FORM{$id} > 0) {
-            SendSQL("INSERT INTO votes (who, bug_id, count) 
+            SendSQL("INSERT INTO votes (who, bug_id, vote_count) 
                      VALUES ($who, $id, $::FORM{$id})");
         }
         
@@ -327,7 +327,7 @@ sub record_votes {
     
     # Update the cached values in the bugs table
     foreach my $id (keys %affected) {
-        SendSQL("SELECT sum(count) FROM votes WHERE bug_id = $id");
+        SendSQL("SELECT sum(vote_count) FROM votes WHERE bug_id = $id");
         my $v = FetchOneColumn();
         $v ||= 0;
         SendSQL("UPDATE bugs SET votes = $v, delta_ts=delta_ts