diff options
author | mkanat%bugzilla.org <> | 2007-03-06 01:29:24 +0000 |
---|---|---|
committer | mkanat%bugzilla.org <> | 2007-03-06 01:29:24 +0000 |
commit | b1a24eebebdab3a6fbae9bd8fd99736e130da0a9 (patch) | |
tree | 966260ebad798a87080b32b30734b890c6327cc5 | |
parent | ae1857494e5bc3dc6a4b87c0e0e329c0c76108bc (diff) | |
download | bugs-b1a24eebebdab3a6fbae9bd8fd99736e130da0a9.tar bugs-b1a24eebebdab3a6fbae9bd8fd99736e130da0a9.tar.gz bugs-b1a24eebebdab3a6fbae9bd8fd99736e130da0a9.tar.bz2 bugs-b1a24eebebdab3a6fbae9bd8fd99736e130da0a9.tar.xz bugs-b1a24eebebdab3a6fbae9bd8fd99736e130da0a9.zip |
Bug 372533: Bugzilla::Object->update throws a warning if some values are undefined
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=LpSolit
-rw-r--r-- | Bugzilla/Object.pm | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/Bugzilla/Object.pm b/Bugzilla/Object.pm index 30ecc77e2..ae4fbeebf 100644 --- a/Bugzilla/Object.pm +++ b/Bugzilla/Object.pm @@ -173,15 +173,23 @@ sub update { my (@update_columns, @values, %changes); foreach my $column ($self->UPDATE_COLUMNS) { - if ($old_self->{$column} ne $self->{$column}) { - my $value = $self->{$column}; - trick_taint($value) if defined $value; - push(@values, $value); - push(@update_columns, $column); - # We don't use $value because we don't want to detaint this for - # the caller. - $changes{$column} = [$old_self->{$column}, $self->{$column}]; + my ($old, $new) = ($old_self->{$column}, $self->{$column}); + # This has to be written this way in order to allow us to set a field + # from undef or to undef, and avoid warnings about comparing an undef + # with the "eq" operator. + if (!defined $new || !defined $old) { + next if !defined $new && !defined $old; } + elsif ($old eq $new) { + next; + } + + trick_taint($new) if defined $new; + push(@values, $new); + push(@update_columns, $column); + # We don't use $new because we don't want to detaint this for + # the caller. + $changes{$column} = [$old, $self->{$column}]; } my $columns = join(', ', map {"$_ = ?"} @update_columns); |