Commit 8449ddc1 authored by bbaetz%acm.org's avatar bbaetz%acm.org

Bug 180086 - Rename 'count' column in votes tables

patch by bugzilla@chimpychompy.org (GavinS) r=bbaetz,justdave a=justdave
parent f016a798
...@@ -140,7 +140,7 @@ sub initBug { ...@@ -140,7 +140,7 @@ sub initBug {
reporter, bug_file_loc, short_desc, target_milestone, reporter, bug_file_loc, short_desc, target_milestone,
qa_contact, status_whiteboard, qa_contact, status_whiteboard,
DATE_FORMAT(creation_ts,'%Y.%m.%d %H:%i'), DATE_FORMAT(creation_ts,'%Y.%m.%d %H:%i'),
delta_ts, sum(votes.count), delta_ts, sum(votes.vote_count),
reporter_accessible, cclist_accessible, reporter_accessible, cclist_accessible,
estimated_time, remaining_time estimated_time, remaining_time
from bugs left join votes using(bug_id), from bugs left join votes using(bug_id),
......
...@@ -140,7 +140,7 @@ sub initBug { ...@@ -140,7 +140,7 @@ sub initBug {
reporter, bug_file_loc, short_desc, target_milestone, reporter, bug_file_loc, short_desc, target_milestone,
qa_contact, status_whiteboard, qa_contact, status_whiteboard,
DATE_FORMAT(creation_ts,'%Y.%m.%d %H:%i'), DATE_FORMAT(creation_ts,'%Y.%m.%d %H:%i'),
delta_ts, sum(votes.count), delta_ts, sum(votes.vote_count),
reporter_accessible, cclist_accessible, reporter_accessible, cclist_accessible,
estimated_time, remaining_time estimated_time, remaining_time
from bugs left join votes using(bug_id), from bugs left join votes using(bug_id),
......
...@@ -1356,7 +1356,7 @@ print "\n" unless $silent; ...@@ -1356,7 +1356,7 @@ print "\n" unless $silent;
# safer than the make*.sh shell scripts used to be, because they won't # safer than the make*.sh shell scripts used to be, because they won't
# delete existing tables. # 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: # checksetup, e.g. like this:
# #
# $ mysql bugs # $ mysql bugs
...@@ -1659,7 +1659,7 @@ $table{versions} = ...@@ -1659,7 +1659,7 @@ $table{versions} =
$table{votes} = $table{votes} =
'who mediumint not null, 'who mediumint not null,
bug_id mediumint not null, bug_id mediumint not null,
count smallint not null, vote_count smallint not null,
index(who), index(who),
index(bug_id)'; index(bug_id)';
...@@ -3869,11 +3869,21 @@ if (TableExists('shadowlog')) { ...@@ -3869,11 +3869,21 @@ if (TableExists('shadowlog')) {
$dbh->do("DROP TABLE shadowlog"); $dbh->do("DROP TABLE shadowlog");
} }
# 2003-04-24 - myk@mozilla.org/bbaetz@acm.org, bug 201018 # 2003-04-XX - bugzilla@chimpychompy.org (GavinS)
# 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 # Bug 180086 (http://bugzilla.mozilla.org/show_bug.cgi?id=180086)
# update doesn't happen on every run #
$dbh->do("UPDATE profiles SET refreshed_when='1900-01-01 00:00:00'"); # 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... # Final checks...
......
...@@ -1170,7 +1170,7 @@ if ($action eq 'update') { ...@@ -1170,7 +1170,7 @@ if ($action eq 'update') {
"FROM votes, bugs " . "FROM votes, bugs " .
"WHERE bugs.bug_id = votes.bug_id " . "WHERE bugs.bug_id = votes.bug_id " .
" AND bugs.product_id = $product_id " . " AND bugs.product_id = $product_id " .
" AND votes.count > $maxvotesperbug"); " AND votes.vote_count > $maxvotesperbug");
my @list; my @list;
while (MoreSQLData()) { while (MoreSQLData()) {
my ($who, $id) = (FetchSQLData()); my ($who, $id) = (FetchSQLData());
...@@ -1183,7 +1183,7 @@ if ($action eq 'update') { ...@@ -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}; 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 " . "WHERE bugs.bug_id = votes.bug_id " .
" AND bugs.product_id = $product_id"); " AND bugs.product_id = $product_id");
my %counts; my %counts;
......
...@@ -1355,7 +1355,7 @@ sub RemoveVotes { ...@@ -1355,7 +1355,7 @@ sub RemoveVotes {
if ($who) { if ($who) {
$whopart = " AND votes.who = $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 " . "products.votesperuser, products.maxvotesperbug " .
"FROM profiles " . "FROM profiles " .
"LEFT JOIN votes ON profiles.userid = votes.who " . "LEFT JOIN votes ON profiles.userid = votes.who " .
...@@ -1393,7 +1393,7 @@ sub RemoveVotes { ...@@ -1393,7 +1393,7 @@ sub RemoveVotes {
my $newvotestext; my $newvotestext;
if ($newvotes) { if ($newvotes) {
SendSQL("UPDATE votes SET count = $newvotes " . SendSQL("UPDATE votes SET vote_count = $newvotes " .
"WHERE bug_id = $id AND who = $userid"); "WHERE bug_id = $id AND who = $userid");
$s = $newvotes == 1 ? "" : "s"; $s = $newvotes == 1 ? "" : "s";
$newvotestext = "You still have $newvotes vote$s on this bug." $newvotestext = "You still have $newvotes vote$s on this bug."
...@@ -1436,7 +1436,7 @@ sub RemoveVotes { ...@@ -1436,7 +1436,7 @@ sub RemoveVotes {
close SENDMAIL; 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(); my $v = FetchOneColumn();
$v ||= 0; $v ||= 0;
SendSQL("UPDATE bugs SET votes = $v, delta_ts = delta_ts " . SendSQL("UPDATE bugs SET votes = $v, delta_ts = delta_ts " .
......
...@@ -82,7 +82,7 @@ if (exists $::FORM{'rebuildvotecache'}) { ...@@ -82,7 +82,7 @@ if (exists $::FORM{'rebuildvotecache'}) {
Status("OK, now rebuilding vote cache."); Status("OK, now rebuilding vote cache.");
SendSQL("lock tables bugs write, votes read"); SendSQL("lock tables bugs write, votes read");
SendSQL("update bugs set votes = 0, delta_ts=delta_ts"); 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; my %votes;
while (@row = FetchSQLData()) { while (@row = FetchSQLData()) {
my ($id, $v) = (@row); my ($id, $v) = (@row);
...@@ -433,7 +433,7 @@ while (@row = FetchSQLData()) { ...@@ -433,7 +433,7 @@ while (@row = FetchSQLData()) {
} }
Status("Checking cached vote counts"); 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()) { while (@row = FetchSQLData()) {
my ($id, $v) = (@row); my ($id, $v) = (@row);
......
...@@ -92,7 +92,7 @@ sub show_bug { ...@@ -92,7 +92,7 @@ sub show_bug {
my $total = 0; my $total = 0;
my @users; my @users;
SendSQL("SELECT profiles.login_name, votes.who, votes.count SendSQL("SELECT profiles.login_name, votes.who, votes.vote_count
FROM votes, profiles FROM votes, profiles
WHERE votes.bug_id = $bug_id WHERE votes.bug_id = $bug_id
AND profiles.userid = votes.who"); AND profiles.userid = votes.who");
...@@ -137,10 +137,10 @@ sub show_user { ...@@ -137,10 +137,10 @@ sub show_user {
if ($canedit && $bug_id) { if ($canedit && $bug_id) {
# Make sure there is an entry for this bug # Make sure there is an entry for this bug
# in the vote table, just so that things display right. # 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"); WHERE votes.bug_id = $bug_id AND votes.who = $who");
if (!FetchOneColumn()) { if (!FetchOneColumn()) {
SendSQL("INSERT INTO votes (who, bug_id, count) SendSQL("INSERT INTO votes (who, bug_id, vote_count)
VALUES ($who, $bug_id, 0)"); VALUES ($who, $bug_id, 0)");
} }
} }
...@@ -167,7 +167,7 @@ sub show_user { ...@@ -167,7 +167,7 @@ sub show_user {
my $total = 0; my $total = 0;
my $onevoteonly = 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 bugs.bug_status
FROM votes, bugs, products FROM votes, bugs, products
WHERE votes.who = $who WHERE votes.who = $who
...@@ -207,7 +207,7 @@ sub show_user { ...@@ -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"); SendSQL("UNLOCK TABLES");
$vars->{'voting_user'} = { "login" => $name }; $vars->{'voting_user'} = { "login" => $name };
...@@ -318,7 +318,7 @@ sub record_votes { ...@@ -318,7 +318,7 @@ sub record_votes {
# Insert the new values in their place # Insert the new values in their place
foreach my $id (@buglist) { foreach my $id (@buglist) {
if ($::FORM{$id} > 0) { 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})"); VALUES ($who, $id, $::FORM{$id})");
} }
...@@ -327,7 +327,7 @@ sub record_votes { ...@@ -327,7 +327,7 @@ sub record_votes {
# Update the cached values in the bugs table # Update the cached values in the bugs table
foreach my $id (keys %affected) { 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(); my $v = FetchOneColumn();
$v ||= 0; $v ||= 0;
SendSQL("UPDATE bugs SET votes = $v, delta_ts=delta_ts SendSQL("UPDATE bugs SET votes = $v, delta_ts=delta_ts
......
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