Commit b1a24eeb authored by mkanat%bugzilla.org's avatar mkanat%bugzilla.org

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
parent ae185749
...@@ -173,15 +173,23 @@ sub update { ...@@ -173,15 +173,23 @@ sub update {
my (@update_columns, @values, %changes); my (@update_columns, @values, %changes);
foreach my $column ($self->UPDATE_COLUMNS) { foreach my $column ($self->UPDATE_COLUMNS) {
if ($old_self->{$column} ne $self->{$column}) { my ($old, $new) = ($old_self->{$column}, $self->{$column});
my $value = $self->{$column}; # This has to be written this way in order to allow us to set a field
trick_taint($value) if defined $value; # from undef or to undef, and avoid warnings about comparing an undef
push(@values, $value); # with the "eq" operator.
push(@update_columns, $column); if (!defined $new || !defined $old) {
# We don't use $value because we don't want to detaint this for next if !defined $new && !defined $old;
# the caller.
$changes{$column} = [$old_self->{$column}, $self->{$column}];
} }
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); my $columns = join(', ', map {"$_ = ?"} @update_columns);
......
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