From 5bb8c229f9dcbf2faf366ee7adce11ee388fc593 Mon Sep 17 00:00:00 2001 From: "myk%mozilla.org" Date: Sun, 19 Aug 2001 18:26:21 +0000 Subject: [PATCH] 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 and Myk Melez . r=myk@mozilla.org,justdave@syndicomm.com --- webtools/bugzilla/checksetup.pl | 16 +++++++++------- webtools/bugzilla/globals.pl | 22 ++++++++++------------ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/webtools/bugzilla/checksetup.pl b/webtools/bugzilla/checksetup.pl index 4eeec8ef15f9..4c3ab81d3cec 100755 --- a/webtools/bugzilla/checksetup.pl +++ b/webtools/bugzilla/checksetup.pl @@ -2405,25 +2405,27 @@ if (GetFieldDef('bugs_activity', 'oldvalue')) { 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); + # print the iteration count every 500 records so the user knows we didn't die + print "$i..." if !($i++ % 500); # Make sure (old|new)value isn't null (to suppress warnings) $oldvalue ||= ""; $newvalue ||= ""; 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 @old = split(/[ ,]/, $oldvalue); - my @new = split(/[ ,]/, $newvalue); # Find values that were "added" foreach my $value(@new) { - if (! grep /^$value$/, @old) { + if (! grep ($_ eq $value, @old)) { push (@add, $value); } } # Find values that were removed foreach my $value(@old) { - if (! grep /^$value$/, @new) { + if (! grep ($_ eq $value, @new)) { push (@remove, $value); } } diff --git a/webtools/bugzilla/globals.pl b/webtools/bugzilla/globals.pl index 3d14c915380f..a3ea97c40154 100644 --- a/webtools/bugzilla/globals.pl +++ b/webtools/bugzilla/globals.pl @@ -1295,24 +1295,22 @@ sub Param ($) { sub DiffStrings { 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 @old = split(/[ ,]/, $oldstr); - my @new = split(/[ ,]/, $newstr); # Find values that were removed - foreach my $value(@old) { - next if $value =~ /^\s*$/; - if (! grep /^$value$/, @new) { - push (@remove, $value); - } + foreach my $value (@old) { + push (@remove, $value) if !grep($_ eq $value, @new); } # Find values that were added - foreach my $value(@new) { - next if $value =~ /^\s*$/; - if (! grep /^$value$/, @old) { - push (@add, $value); - } + foreach my $value (@new) { + push (@add, $value) if !grep($_ eq $value, @old); } my $removed = join (", ", @remove);