Commit 5391f72b authored by myk%mozilla.org's avatar myk%mozilla.org

Fix for bug 95890: Correctly convert/record keyword changes in the bugs_activity…

Fix for bug 95890: Correctly convert/record keyword changes in the bugs_activity table for keywords containing a plus sign or other regular expression meta-characters. Myk's first ever Bugzilla checkin! Patch by Dave Miller <justdave@syndicomm.com> and Myk Melez <myk@mozilla.org>. r=myk@mozilla.org,justdave@syndicomm.com
parent 19fac474
...@@ -2405,25 +2405,27 @@ if (GetFieldDef('bugs_activity', 'oldvalue')) { ...@@ -2405,25 +2405,27 @@ if (GetFieldDef('bugs_activity', 'oldvalue')) {
oldvalue, newvalue FROM bugs_activity"); oldvalue, newvalue FROM bugs_activity");
$sth->execute; $sth->execute;
while (my ($bug_id, $who, $bug_when, $fieldid, $oldvalue, $newvalue) = $sth->fetchrow_array()) { 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 the iteration count every 500 records so the user knows we didn't die
print "." if !($i++ % 500); print "$i..." if !($i++ % 500);
# Make sure (old|new)value isn't null (to suppress warnings) # Make sure (old|new)value isn't null (to suppress warnings)
$oldvalue ||= ""; $oldvalue ||= "";
$newvalue ||= ""; $newvalue ||= "";
my ($added, $removed) = ""; my ($added, $removed) = "";
if (grep /^$fieldid$/, @multi) { if (grep ($_ eq $fieldid, @multi)) {
$oldvalue =~ s/[\s,]+/ /g;
$newvalue =~ s/[\s,]+/ /g;
my @old = split(" ", $oldvalue);
my @new = split(" ", $newvalue);
my (@add, @remove) = (); my (@add, @remove) = ();
my @old = split(/[ ,]/, $oldvalue);
my @new = split(/[ ,]/, $newvalue);
# Find values that were "added" # Find values that were "added"
foreach my $value(@new) { foreach my $value(@new) {
if (! grep /^$value$/, @old) { if (! grep ($_ eq $value, @old)) {
push (@add, $value); push (@add, $value);
} }
} }
# Find values that were removed # Find values that were removed
foreach my $value(@old) { foreach my $value(@old) {
if (! grep /^$value$/, @new) { if (! grep ($_ eq $value, @new)) {
push (@remove, $value); push (@remove, $value);
} }
} }
......
...@@ -1295,24 +1295,22 @@ sub Param ($) { ...@@ -1295,24 +1295,22 @@ sub Param ($) {
sub DiffStrings { sub DiffStrings {
my ($oldstr, $newstr) = @_; my ($oldstr, $newstr) = @_;
# Split the old and new strings into arrays containing their values.
$oldstr =~ s/[\s,]+/ /g;
$newstr =~ s/[\s,]+/ /g;
my @old = split(" ", $oldstr);
my @new = split(" ", $newstr);
my (@remove, @add) = (); my (@remove, @add) = ();
my @old = split(/[ ,]/, $oldstr);
my @new = split(/[ ,]/, $newstr);
# Find values that were removed # Find values that were removed
foreach my $value(@old) { foreach my $value (@old) {
next if $value =~ /^\s*$/; push (@remove, $value) if !grep($_ eq $value, @new);
if (! grep /^$value$/, @new) {
push (@remove, $value);
}
} }
# Find values that were added # Find values that were added
foreach my $value(@new) { foreach my $value (@new) {
next if $value =~ /^\s*$/; push (@add, $value) if !grep($_ eq $value, @old);
if (! grep /^$value$/, @old) {
push (@add, $value);
}
} }
my $removed = join (", ", @remove); my $removed = join (", ", @remove);
......
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