Commit 344149d0 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 322285: Cancelling a flag should remove it completely from the DB - Patch by…

Bug 322285: Cancelling a flag should remove it completely from the DB - Patch by Frédéric Buclin <LpSolit@gmail.com> r/a=myk
parent bd0e09be
...@@ -373,8 +373,7 @@ sub flags { ...@@ -373,8 +373,7 @@ sub flags {
my $self = shift; my $self = shift;
return $self->{flags} if exists $self->{flags}; return $self->{flags} if exists $self->{flags};
$self->{flags} = Bugzilla::Flag::match({ attach_id => $self->id, $self->{flags} = Bugzilla::Flag::match({ 'attach_id' => $self->id });
is_active => 1 });
return $self->{flags}; return $self->{flags};
} }
......
...@@ -429,8 +429,7 @@ sub flag_types { ...@@ -429,8 +429,7 @@ sub flag_types {
$flag_type->{'flags'} = Bugzilla::Flag::match( $flag_type->{'flags'} = Bugzilla::Flag::match(
{ 'bug_id' => $self->bug_id, { 'bug_id' => $self->bug_id,
'type_id' => $flag_type->{'id'}, 'type_id' => $flag_type->{'id'},
'target_type' => 'bug', 'target_type' => 'bug' });
'is_active' => 1 });
} }
$self->{'flag_types'} = $flag_types; $self->{'flag_types'} = $flag_types;
...@@ -515,8 +514,7 @@ sub show_attachment_flags { ...@@ -515,8 +514,7 @@ sub show_attachment_flags {
'component_id' => $self->{'component_id'} }); 'component_id' => $self->{'component_id'} });
my $num_attachment_flags = Bugzilla::Flag::count( my $num_attachment_flags = Bugzilla::Flag::count(
{ 'target_type' => 'attachment', { 'target_type' => 'attachment',
'bug_id' => $self->bug_id, 'bug_id' => $self->bug_id });
'is_active' => 1 });
$self->{'show_attachment_flags'} = $self->{'show_attachment_flags'} =
($num_attachment_flag_types || $num_attachment_flags); ($num_attachment_flag_types || $num_attachment_flags);
......
...@@ -375,7 +375,7 @@ use constant ABSTRACT_SCHEMA => { ...@@ -375,7 +375,7 @@ use constant ABSTRACT_SCHEMA => {
# "flags" stores one record for each flag on each bug/attachment. # "flags" stores one record for each flag on each bug/attachment.
flags => { flags => {
FIELDS => [ FIELDS => [
id => {TYPE => 'INT3', NOTNULL => 1, id => {TYPE => 'MEDIUMSERIAL', NOTNULL => 1,
PRIMARYKEY => 1}, PRIMARYKEY => 1},
type_id => {TYPE => 'INT2', NOTNULL => 1}, type_id => {TYPE => 'INT2', NOTNULL => 1},
status => {TYPE => 'char(1)', NOTNULL => 1}, status => {TYPE => 'char(1)', NOTNULL => 1},
...@@ -385,8 +385,6 @@ use constant ABSTRACT_SCHEMA => { ...@@ -385,8 +385,6 @@ use constant ABSTRACT_SCHEMA => {
modification_date => {TYPE => 'DATETIME'}, modification_date => {TYPE => 'DATETIME'},
setter_id => {TYPE => 'INT3'}, setter_id => {TYPE => 'INT3'},
requestee_id => {TYPE => 'INT3'}, requestee_id => {TYPE => 'INT3'},
is_active => {TYPE => 'BOOLEAN', NOTNULL => 1,
DEFAULT => 'TRUE'},
], ],
INDEXES => [ INDEXES => [
flags_bug_id_idx => [qw(bug_id attach_id)], flags_bug_id_idx => [qw(bug_id attach_id)],
......
...@@ -94,7 +94,7 @@ database. B<Used by get, match, sqlify_criteria and perlify_record> ...@@ -94,7 +94,7 @@ database. B<Used by get, match, sqlify_criteria and perlify_record>
=cut =cut
my @base_columns = my @base_columns =
("is_active", "id", "type_id", "bug_id", "attach_id", "requestee_id", ("id", "type_id", "bug_id", "attach_id", "requestee_id",
"setter_id", "status"); "setter_id", "status");
=pod =pod
...@@ -284,11 +284,6 @@ sub validate { ...@@ -284,11 +284,6 @@ sub validate {
my $flag = get($id); my $flag = get($id);
$flag || ThrowCodeError("flag_nonexistent", { id => $id }); $flag || ThrowCodeError("flag_nonexistent", { id => $id });
# Note that the deletedness of the flag (is_active or not) is not
# checked here; we do want to allow changes to deleted flags in
# certain cases. Flag::modify() will revive the modified flags.
# See bug 223878 for details.
# Make sure the user chose a valid status. # Make sure the user chose a valid status.
grep($status eq $_, qw(X + - ?)) grep($status eq $_, qw(X + - ?))
|| ThrowCodeError("flag_status_invalid", || ThrowCodeError("flag_status_invalid",
...@@ -398,8 +393,7 @@ sub snapshot { ...@@ -398,8 +393,7 @@ sub snapshot {
my ($bug_id, $attach_id) = @_; my ($bug_id, $attach_id) = @_;
my $flags = match({ 'bug_id' => $bug_id, my $flags = match({ 'bug_id' => $bug_id,
'attach_id' => $attach_id, 'attach_id' => $attach_id });
'is_active' => 1 });
my @summaries; my @summaries;
foreach my $flag (@$flags) { foreach my $flag (@$flags) {
my $summary = $flag->{'type'}->{'name'} . $flag->{'status'}; my $summary = $flag->{'type'}->{'name'} . $flag->{'status'};
...@@ -466,7 +460,6 @@ sub process { ...@@ -466,7 +460,6 @@ sub process {
AND (bugs.product_id = i.product_id OR i.product_id IS NULL) AND (bugs.product_id = i.product_id OR i.product_id IS NULL)
AND (bugs.component_id = i.component_id OR i.component_id IS NULL) AND (bugs.component_id = i.component_id OR i.component_id IS NULL)
WHERE bugs.bug_id = ? WHERE bugs.bug_id = ?
AND flags.is_active = 1
AND i.type_id IS NULL", AND i.type_id IS NULL",
undef, $bug_id); undef, $bug_id);
...@@ -478,7 +471,6 @@ sub process { ...@@ -478,7 +471,6 @@ sub process {
WHERE bugs.bug_id = ? WHERE bugs.bug_id = ?
AND flags.bug_id = bugs.bug_id AND flags.bug_id = bugs.bug_id
AND flags.type_id = e.type_id AND flags.type_id = e.type_id
AND flags.is_active = 1
AND (bugs.product_id = e.product_id OR e.product_id IS NULL) AND (bugs.product_id = e.product_id OR e.product_id IS NULL)
AND (bugs.component_id = e.component_id OR e.component_id IS NULL)", AND (bugs.component_id = e.component_id OR e.component_id IS NULL)",
undef, $bug_id); undef, $bug_id);
...@@ -529,22 +521,15 @@ Creates a flag record in the database. ...@@ -529,22 +521,15 @@ Creates a flag record in the database.
sub create { sub create {
my ($flag, $timestamp) = @_; my ($flag, $timestamp) = @_;
# Determine the ID for the flag record by retrieving the last ID used
# and incrementing it.
&::SendSQL("SELECT MAX(id) FROM flags");
$flag->{'id'} = (&::FetchOneColumn() || 0) + 1;
# Insert a record for the flag into the flags table.
my $attach_id = my $attach_id =
$flag->{target}->{attachment} ? $flag->{target}->{attachment}->{id} $flag->{target}->{attachment} ? $flag->{target}->{attachment}->{id}
: "NULL"; : "NULL";
my $requestee_id = $flag->{'requestee'} ? $flag->{'requestee'}->id : "NULL"; my $requestee_id = $flag->{'requestee'} ? $flag->{'requestee'}->id : "NULL";
&::SendSQL("INSERT INTO flags (id, type_id,
bug_id, attach_id, &::SendSQL("INSERT INTO flags (type_id, bug_id, attach_id,
requestee_id, setter_id, status, requestee_id, setter_id, status,
creation_date, modification_date) creation_date, modification_date)
VALUES ($flag->{'id'}, VALUES ($flag->{'type'}->{'id'},
$flag->{'type'}->{'id'},
$flag->{'target'}->{'bug'}->{'id'}, $flag->{'target'}->{'bug'}->{'id'},
$attach_id, $attach_id,
$requestee_id, $requestee_id,
...@@ -597,9 +582,6 @@ sub migrate { ...@@ -597,9 +582,6 @@ sub migrate {
=item C<modify($cgi, $timestamp)> =item C<modify($cgi, $timestamp)>
Modifies flags in the database when a user changes them. Modifies flags in the database when a user changes them.
Note that modified flags are always set active (is_active = 1) -
this will revive deleted flags that get changed through
attachment.cgi midairs. See bug 223878 for details.
=back =back
...@@ -681,8 +663,7 @@ sub modify { ...@@ -681,8 +663,7 @@ sub modify {
SET setter_id = " . $setter->id . ", SET setter_id = " . $setter->id . ",
requestee_id = NULL , requestee_id = NULL ,
status = '$status' , status = '$status' ,
modification_date = $timestamp , modification_date = $timestamp
is_active = 1
WHERE id = $flag->{'id'}"); WHERE id = $flag->{'id'}");
# If the status of the flag was "?", we have to notify # If the status of the flag was "?", we have to notify
...@@ -722,8 +703,7 @@ sub modify { ...@@ -722,8 +703,7 @@ sub modify {
SET setter_id = " . $setter->id . ", SET setter_id = " . $setter->id . ",
requestee_id = $requestee_id , requestee_id = $requestee_id ,
status = '$status' , status = '$status' ,
modification_date = $timestamp , modification_date = $timestamp
is_active = 1
WHERE id = $flag->{'id'}"); WHERE id = $flag->{'id'}");
# Now update the flag object with its new values. # Now update the flag object with its new values.
...@@ -739,7 +719,6 @@ sub modify { ...@@ -739,7 +719,6 @@ sub modify {
notify($flag, "request/email.txt.tmpl"); notify($flag, "request/email.txt.tmpl");
} }
# The user unset the flag; set is_active = 0
elsif ($status eq 'X') { elsif ($status eq 'X') {
clear($flag->{'id'}); clear($flag->{'id'});
} }
...@@ -756,7 +735,7 @@ sub modify { ...@@ -756,7 +735,7 @@ sub modify {
=item C<clear($id)> =item C<clear($id)>
Deactivate a flag. Remove a flag from the DB.
=back =back
...@@ -764,12 +743,10 @@ Deactivate a flag. ...@@ -764,12 +743,10 @@ Deactivate a flag.
sub clear { sub clear {
my ($id) = @_; my ($id) = @_;
my $dbh = Bugzilla->dbh;
my $flag = get($id); my $flag = get($id);
$dbh->do('DELETE FROM flags WHERE id = ?', undef, $id);
&::PushGlobalSQLState();
&::SendSQL("UPDATE flags SET is_active = 0 WHERE id = $id");
&::PopGlobalSQLState();
# If we cancel a pending request, we have to notify the requester # If we cancel a pending request, we have to notify the requester
# (if he wants to). # (if he wants to).
...@@ -834,17 +811,16 @@ sub FormToNewFlags { ...@@ -834,17 +811,16 @@ sub FormToNewFlags {
# We are only interested in flags the user tries to create. # We are only interested in flags the user tries to create.
next unless scalar(grep { $_ == $type_id } @type_ids); next unless scalar(grep { $_ == $type_id } @type_ids);
# Get the number of active flags of this type already set for this target. # Get the number of flags of this type already set for this target.
my $has_flags = count( my $has_flags = count(
{ 'type_id' => $type_id, { 'type_id' => $type_id,
'target_type' => $target->{'type'}, 'target_type' => $target->{'type'},
'bug_id' => $target->{'bug'}->{'id'}, 'bug_id' => $target->{'bug'}->{'id'},
'attach_id' => $target->{'attachment'} ? 'attach_id' => $target->{'attachment'} ?
$target->{'attachment'}->{'id'} : undef, $target->{'attachment'}->{'id'} : undef });
'is_active' => 1 });
# Do not create a new flag of this type if this flag type is # Do not create a new flag of this type if this flag type is
# not multiplicable and already has an active flag set. # not multiplicable and already has a flag set.
next if (!$flag_type->{'is_multiplicable'} && $has_flags); next if (!$flag_type->{'is_multiplicable'} && $has_flags);
my $status = $cgi->param("flag_type-$type_id"); my $status = $cgi->param("flag_type-$type_id");
...@@ -1032,7 +1008,6 @@ sub CancelRequests { ...@@ -1032,7 +1008,6 @@ sub CancelRequests {
LEFT JOIN attachments ON flags.attach_id = attachments.attach_id LEFT JOIN attachments ON flags.attach_id = attachments.attach_id
WHERE flags.attach_id = ? WHERE flags.attach_id = ?
AND flags.status = '?' AND flags.status = '?'
AND flags.is_active = 1
AND attachments.isobsolete = 0", AND attachments.isobsolete = 0",
undef, $attach_id); undef, $attach_id);
...@@ -1094,7 +1069,6 @@ sub sqlify_criteria { ...@@ -1094,7 +1069,6 @@ sub sqlify_criteria {
elsif ($field eq 'requestee_id') { push(@criteria, "requestee_id = $value") } elsif ($field eq 'requestee_id') { push(@criteria, "requestee_id = $value") }
elsif ($field eq 'setter_id') { push(@criteria, "setter_id = $value") } elsif ($field eq 'setter_id') { push(@criteria, "setter_id = $value") }
elsif ($field eq 'status') { push(@criteria, "status = '$value'") } elsif ($field eq 'status') { push(@criteria, "status = '$value'") }
elsif ($field eq 'is_active') { push(@criteria, "is_active = $value") }
} }
return @criteria; return @criteria;
...@@ -1115,14 +1089,13 @@ Converts a row from the database into a Perl record. ...@@ -1115,14 +1089,13 @@ Converts a row from the database into a Perl record.
=cut =cut
sub perlify_record { sub perlify_record {
my ($exists, $id, $type_id, $bug_id, $attach_id, my ($id, $type_id, $bug_id, $attach_id,
$requestee_id, $setter_id, $status) = @_; $requestee_id, $setter_id, $status) = @_;
return undef unless defined($exists); return undef unless $id;
my $flag = my $flag =
{ {
exists => $exists ,
id => $id , id => $id ,
type => Bugzilla::FlagType::get($type_id) , type => Bugzilla::FlagType::get($type_id) ,
target => get_target($bug_id, $attach_id) , target => get_target($bug_id, $attach_id) ,
...@@ -1153,6 +1126,8 @@ sub perlify_record { ...@@ -1153,6 +1126,8 @@ sub perlify_record {
=item Kevin Benton <kevin.benton@amd.com> =item Kevin Benton <kevin.benton@amd.com>
=item Frédéric Buclin <LpSolit@gmail.com>
=back =back
=cut =cut
......
...@@ -474,7 +474,6 @@ sub normalize { ...@@ -474,7 +474,6 @@ sub normalize {
AND (bugs.product_id = i.product_id OR i.product_id IS NULL) AND (bugs.product_id = i.product_id OR i.product_id IS NULL)
AND (bugs.component_id = i.component_id OR i.component_id IS NULL)) AND (bugs.component_id = i.component_id OR i.component_id IS NULL))
WHERE flags.type_id IN ($ids) WHERE flags.type_id IN ($ids)
AND flags.is_active = 1
AND i.type_id IS NULL AND i.type_id IS NULL
"); ");
Bugzilla::Flag::clear(&::FetchOneColumn()) while &::MoreSQLData(); Bugzilla::Flag::clear(&::FetchOneColumn()) while &::MoreSQLData();
...@@ -485,7 +484,6 @@ sub normalize { ...@@ -485,7 +484,6 @@ sub normalize {
WHERE flags.type_id IN ($ids) WHERE flags.type_id IN ($ids)
AND flags.bug_id = bugs.bug_id AND flags.bug_id = bugs.bug_id
AND flags.type_id = e.type_id AND flags.type_id = e.type_id
AND flags.is_active = 1
AND (bugs.product_id = e.product_id OR e.product_id IS NULL) AND (bugs.product_id = e.product_id OR e.product_id IS NULL)
AND (bugs.component_id = e.component_id OR e.component_id IS NULL) AND (bugs.component_id = e.component_id OR e.component_id IS NULL)
"); ");
......
...@@ -843,8 +843,7 @@ sub init { ...@@ -843,8 +843,7 @@ sub init {
# negative conditions (f.e. "flag isn't review+"). # negative conditions (f.e. "flag isn't review+").
my $flags = "flags_$chartid"; my $flags = "flags_$chartid";
push(@supptables, "LEFT JOIN flags AS $flags " . push(@supptables, "LEFT JOIN flags AS $flags " .
"ON bugs.bug_id = $flags.bug_id " . "ON bugs.bug_id = $flags.bug_id ");
"AND $flags.is_active = 1");
my $flagtypes = "flagtypes_$chartid"; my $flagtypes = "flagtypes_$chartid";
push(@supptables, "LEFT JOIN flagtypes AS $flagtypes " . push(@supptables, "LEFT JOIN flagtypes AS $flagtypes " .
"ON $flags.type_id = $flagtypes.id"); "ON $flags.type_id = $flagtypes.id");
...@@ -874,8 +873,7 @@ sub init { ...@@ -874,8 +873,7 @@ sub init {
"^requestees.login_name," => sub { "^requestees.login_name," => sub {
my $flags = "flags_$chartid"; my $flags = "flags_$chartid";
push(@supptables, "LEFT JOIN flags AS $flags " . push(@supptables, "LEFT JOIN flags AS $flags " .
"ON bugs.bug_id = $flags.bug_id " . "ON bugs.bug_id = $flags.bug_id ");
"AND $flags.is_active = 1");
push(@supptables, "LEFT JOIN profiles AS requestees_$chartid " . push(@supptables, "LEFT JOIN profiles AS requestees_$chartid " .
"ON $flags.requestee_id = requestees_$chartid.userid"); "ON $flags.requestee_id = requestees_$chartid.userid");
$f = "requestees_$chartid.login_name"; $f = "requestees_$chartid.login_name";
...@@ -883,8 +881,7 @@ sub init { ...@@ -883,8 +881,7 @@ sub init {
"^setters.login_name," => sub { "^setters.login_name," => sub {
my $flags = "flags_$chartid"; my $flags = "flags_$chartid";
push(@supptables, "LEFT JOIN flags AS $flags " . push(@supptables, "LEFT JOIN flags AS $flags " .
"ON bugs.bug_id = $flags.bug_id " . "ON bugs.bug_id = $flags.bug_id ");
"AND $flags.is_active = 1");
push(@supptables, "LEFT JOIN profiles AS setters_$chartid " . push(@supptables, "LEFT JOIN profiles AS setters_$chartid " .
"ON $flags.setter_id = setters_$chartid.userid"); "ON $flags.setter_id = setters_$chartid.userid");
$f = "setters_$chartid.login_name"; $f = "setters_$chartid.login_name";
......
...@@ -836,8 +836,7 @@ sub viewall ...@@ -836,8 +836,7 @@ sub viewall
{ {
$a->{'isviewable'} = isViewable($a->{'contenttype'}); $a->{'isviewable'} = isViewable($a->{'contenttype'});
$a->{'flags'} = Bugzilla::Flag::match({ 'attach_id' => $a->{'attachid'}, $a->{'flags'} = Bugzilla::Flag::match({ 'attach_id' => $a->{'attachid'} });
'is_active' => 1 });
} }
# Retrieve the bug summary (for displaying on screen) and assignee. # Retrieve the bug summary (for displaying on screen) and assignee.
...@@ -1151,8 +1150,7 @@ sub edit { ...@@ -1151,8 +1150,7 @@ sub edit {
'component_id' => $component_id }); 'component_id' => $component_id });
foreach my $flag_type (@$flag_types) { foreach my $flag_type (@$flag_types) {
$flag_type->{'flags'} = Bugzilla::Flag::match({ 'type_id' => $flag_type->{'id'}, $flag_type->{'flags'} = Bugzilla::Flag::match({ 'type_id' => $flag_type->{'id'},
'attach_id' => $attachment->id, 'attach_id' => $attachment->id });
'is_active' => 1 });
} }
$vars->{'flag_types'} = $flag_types; $vars->{'flag_types'} = $flag_types;
$vars->{'any_flags_requesteeble'} = grep($_->{'is_requesteeble'}, @$flag_types); $vars->{'any_flags_requesteeble'} = grep($_->{'is_requesteeble'}, @$flag_types);
......
...@@ -3621,12 +3621,6 @@ if ($dbh->bz_column_info("user_group_map", "isderived")) { ...@@ -3621,12 +3621,6 @@ if ($dbh->bz_column_info("user_group_map", "isderived")) {
$dbh->do("UPDATE groups SET last_changed = NOW() WHERE name = 'admin'"); $dbh->do("UPDATE groups SET last_changed = NOW() WHERE name = 'admin'");
} }
# 2004-07-03 - Make it possible to disable flags without deleting them
# from the database. Bug 223878, jouni@heikniemi.net
$dbh->bz_add_column('flags', 'is_active',
{TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 'TRUE'});
# 2004-07-16 - Make it possible to have group-group relationships other than # 2004-07-16 - Make it possible to have group-group relationships other than
# membership and bless. # membership and bless.
if ($dbh->bz_column_info("group_group_map", "isbless")) { if ($dbh->bz_column_info("group_group_map", "isbless")) {
...@@ -4283,6 +4277,22 @@ $dbh->bz_add_column('fielddefs', 'custom', ...@@ -4283,6 +4277,22 @@ $dbh->bz_add_column('fielddefs', 'custom',
$dbh->bz_add_column('longdescs', 'comment_id', $dbh->bz_add_column('longdescs', 'comment_id',
{TYPE => 'MEDIUMSERIAL', NOTNULL => 1, PRIMARYKEY => 1}); {TYPE => 'MEDIUMSERIAL', NOTNULL => 1, PRIMARYKEY => 1});
# 2006-03-02 LpSolit@gmail.com - Bug 322285
# Do not store inactive flags in the DB anymore.
if ($dbh->bz_column_info('flags', 'id')->{'TYPE'} eq 'INT3') {
# We first have to remove all existing inactive flags.
if ($dbh->bz_column_info('flags', 'is_active')) {
$dbh->do('DELETE FROM flags WHERE is_active = 0');
}
# Now we convert the id column to the auto_increment format.
$dbh->bz_alter_column('flags', 'id',
{TYPE => 'MEDIUMSERIAL', NOTNULL => 1, PRIMARYKEY => 1});
# And finally, we remove the is_active column.
$dbh->bz_drop_column('flags', 'is_active');
}
# If you had to change the --TABLE-- definition in any way, then add your # If you had to change the --TABLE-- definition in any way, then add your
# differential change code *** A B O V E *** this comment. # differential change code *** A B O V E *** this comment.
# #
......
...@@ -359,7 +359,6 @@ sub update { ...@@ -359,7 +359,6 @@ sub update {
AND (bugs.component_id = i.component_id AND (bugs.component_id = i.component_id
OR i.component_id IS NULL)) OR i.component_id IS NULL))
WHERE flags.type_id = ? WHERE flags.type_id = ?
AND flags.is_active = 1
AND i.type_id IS NULL', AND i.type_id IS NULL',
undef, $id); undef, $id);
foreach my $flag_id (@$flag_ids) { foreach my $flag_id (@$flag_ids) {
...@@ -373,7 +372,6 @@ sub update { ...@@ -373,7 +372,6 @@ sub update {
INNER JOIN flagexclusions AS e INNER JOIN flagexclusions AS e
ON flags.type_id = e.type_id ON flags.type_id = e.type_id
WHERE flags.type_id = ? WHERE flags.type_id = ?
AND flags.is_active = 1
AND (bugs.product_id = e.product_id AND (bugs.product_id = e.product_id
OR e.product_id IS NULL) OR e.product_id IS NULL)
AND (bugs.component_id = e.component_id AND (bugs.component_id = e.component_id
...@@ -401,8 +399,7 @@ sub confirmDelete ...@@ -401,8 +399,7 @@ sub confirmDelete
# check if we need confirmation to delete: # check if we need confirmation to delete:
my $count = Bugzilla::Flag::count({ 'type_id' => $id, my $count = Bugzilla::Flag::count({ 'type_id' => $id });
'is_active' => 1 });
if ($count > 0) { if ($count > 0) {
$vars->{'flag_type'} = Bugzilla::FlagType::get($id); $vars->{'flag_type'} = Bugzilla::FlagType::get($id);
......
...@@ -453,7 +453,7 @@ if ($action eq 'search') { ...@@ -453,7 +453,7 @@ if ($action eq 'search') {
'SELECT COUNT(*) FROM email_setting WHERE user_id = ?', 'SELECT COUNT(*) FROM email_setting WHERE user_id = ?',
undef, $otherUserID); undef, $otherUserID);
$vars->{'flags'}{'requestee'} = $dbh->selectrow_array( $vars->{'flags'}{'requestee'} = $dbh->selectrow_array(
'SELECT COUNT(*) FROM flags WHERE requestee_id = ? AND is_active = 1', 'SELECT COUNT(*) FROM flags WHERE requestee_id = ?',
undef, $otherUserID); undef, $otherUserID);
$vars->{'flags'}{'setter'} = $dbh->selectrow_array( $vars->{'flags'}{'setter'} = $dbh->selectrow_array(
'SELECT COUNT(*) FROM flags WHERE setter_id = ?', 'SELECT COUNT(*) FROM flags WHERE setter_id = ?',
......
...@@ -304,14 +304,12 @@ sub flag_handler { ...@@ -304,14 +304,12 @@ sub flag_handler {
return $err; return $err;
} }
my ($fid) = $dbh->selectrow_array("SELECT MAX(id) FROM flags") || 0;
$dbh->do("INSERT INTO flags $dbh->do("INSERT INTO flags
(id, type_id, status, bug_id, attach_id, creation_date, (type_id, status, bug_id, attach_id, creation_date,
setter_id, requestee_id, is_active) setter_id, requestee_id)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", undef, VALUES (?, ?, ?, ?, ?, ?, ?)", undef,
++$fid, $ftypeid, $status, $bugid, $attachid, $timestamp, ($ftypeid, $status, $bugid, $attachid, $timestamp,
$setter_id, $requestee_id, 1 $setter_id, $requestee_id));
);
} }
else { else {
$err = "Dropping unknown $type flag: $name\n"; $err = "Dropping unknown $type flag: $name\n";
......
...@@ -128,9 +128,6 @@ sub queue { ...@@ -128,9 +128,6 @@ sub queue {
(Param('useqacontact') ? "OR (Param('useqacontact') ? "OR
(bugs.qa_contact = $userid))" : ")"); (bugs.qa_contact = $userid))" : ")");
# Non-deleted flags only
$query .= " AND flags.is_active = 1 ";
# Limit query to pending requests. # Limit query to pending requests.
$query .= " AND flags.status = '?' " unless $status; $query .= " AND flags.status = '?' " unless $status;
......
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