diff options
author | jake%acutex.net <> | 2001-07-21 00:18:25 +0200 |
---|---|---|
committer | jake%acutex.net <> | 2001-07-21 00:18:25 +0200 |
commit | 32c74ca90011bfa5cfc781ca0879529abb3c5d30 (patch) | |
tree | a37625309a4e03167eea6977451b70246fe7fa46 /checksetup.pl | |
parent | 708fafdbfa042bea7e5bb006ca1bdcde69248431 (diff) | |
download | bugzilla-32c74ca90011bfa5cfc781ca0879529abb3c5d30.tar.gz bugzilla-32c74ca90011bfa5cfc781ca0879529abb3c5d30.tar.xz |
Fix for bugs 55161 and 12819. The activity log now stores only what's changed in multi-value fields.
r= justdave@syndicomm.com
Diffstat (limited to 'checksetup.pl')
-rwxr-xr-x | checksetup.pl | 70 |
1 files changed, 68 insertions, 2 deletions
diff --git a/checksetup.pl b/checksetup.pl index 8ce8bf6f7..bcbebff6d 100755 --- a/checksetup.pl +++ b/checksetup.pl @@ -768,8 +768,8 @@ $table{bugs_activity} = who mediumint not null, bug_when datetime not null, fieldid mediumint not null, - oldvalue tinytext, - newvalue tinytext, + added tinytext, + removed tinytext, index (bug_id), index (bug_when), @@ -2307,6 +2307,72 @@ if (!defined GetIndexDef('longdescs','who')) { # truncates re http://bugzilla.mozilla.org/show_bug.cgi?id=9352 ChangeFieldType('bugs', 'version','varchar(64) not null'); +# 2001-07-20 jake@acutex.net - Change bugs_activity to only record changes +# http://bugzilla.mozilla.org/show_bug.cgi?id=55161 +if (GetFieldDef('bugs_activity', 'oldvalue')) { + AddField("bugs_activity", "removed", "tinytext"); + AddField("bugs_activity", "added", "tinytext"); + + # Need to get fieldid's for the fields that have multipule values + my @multi = (); + foreach my $f ("cc", "dependson", "blocked", "keywords") { + my $sth = $dbh->prepare("SELECT fieldid FROM fielddefs WHERE name = '$f'"); + $sth->execute(); + my ($fid) = $sth->fetchrow_array(); + push (@multi, $fid); + } + + # Now we need to process the bugs_activity table and reformat the data + my $i = 0; + print "Fixing activity log "; + my $sth = $dbh->prepare("SELECT bug_id, who, bug_when, fieldid, + oldvalue, newvalue FROM bugs_activity"); + $sth->execute; + while (my ($bug_id, $who, $bug_when, $fieldid, $oldvalue, $newvalue) = $sth->fetchrow_array()) { + # print a "." every 500 records so the user knows we didn't die + print "." if !($i++ % 500); + # Make sure (old|new)value isn't null (to suppress warnings) + $oldvalue ||= ""; + $newvalue ||= ""; + my ($added, $removed) = ""; + if (grep /^$fieldid$/, @multi) { + my (@add, @remove) = (); + my @old = split(/[ ,]/, $oldvalue); + my @new = split(/[ ,]/, $newvalue); + # Find values that were "added" + foreach my $value(@new) { + if (! grep /^$value$/, @old) { + push (@add, $value); + } + } + # Find values that were removed + foreach my $value(@old) { + if (! grep /^$value$/, @new) { + push (@remove, $value); + } + } + $added = join (", ", @add); + $removed = join (", ", @remove); + # If we can't determine what changed, put a ? in both fields + unless ($added || $removed) { + $added = "?"; + $removed = "?"; + } + } else { + $removed = $oldvalue; + $added = $newvalue; + } + $added = $dbh->quote($added); + $removed = $dbh->quote($removed); + $dbh->do("UPDATE bugs_activity SET removed = $removed, added = $added + WHERE bug_id = $bug_id AND who = $who + AND bug_when = '$bug_when' AND fieldid = $fieldid"); + } + print ". Done.\n"; + DropField("bugs_activity", "oldvalue"); + DropField("bugs_activity", "newvalue"); +} + # If you had to change the --TABLE-- definition in any way, then add your # differential change code *** A B O V E *** this comment. # |