Commit fa680969 authored by bugreport%peshkin.net's avatar bugreport%peshkin.net

Bug 250967: Fix spurious updates to requesteeless flags

patch by jouni r=kiko,joel a=justdave
parent ebea3d35
...@@ -374,20 +374,29 @@ sub modify { ...@@ -374,20 +374,29 @@ sub modify {
my $status = $data->{"flag-$id"}; my $status = $data->{"flag-$id"};
my $requestee_email = trim($data->{"requestee-$id"}); my $requestee_email = trim($data->{"requestee-$id"});
# Ignore flags the user didn't change. A flag hasn't changed
# if its status and requestee remain the same. Status is easy; # Ignore flags the user didn't change. There are two components here:
# we just compare the existing status with the submitted one. # either the status changes (trivial) or the requestee changes.
# For requestee, however, we have to be careful not to compare # Change of either field will cause full update of the flag.
# the two if the flag isn't specifically requestable or isn't
# being requested, otherwise we'll get false positives and think my $status_changed = ($status ne $flag->{'status'});
# the user changed the flag when they didn't.
next if # Requestee is considered changed, if all of the following apply:
$status eq $flag->{'status'} # the flag's status hasn't changed, and: # 1. Flag status is '?' (requested)
&& (!$flag->{'type'}->{'is_requesteeble'} # 2. Flag can have a requestee
# the flag isn't specifically requestable # 3. The requestee specified on the form is different from the
|| $status ne "?" # or the flag isn't being requested # requestee specified in the db.
|| ($flag->{'requestee'} # or the requestee hasn't changed
&& ($requestee_email eq $flag->{'requestee'}->login))); my $old_requestee =
$flag->{'requestee'} ? $flag->{'requestee'}->login : '';
my $requestee_changed =
($status eq "?" &&
$flag->{'type'}->{'is_requesteeble'} &&
$old_requestee ne $requestee_email);
next unless ($status_changed || $requestee_changed);
# Since the status is validated, we know it's safe, but it's still # Since the status is validated, we know it's safe, but it's still
# tainted, so we have to detaint it before using it in a query. # tainted, so we have to detaint it before using it in a query.
......
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