my $self = shift;
return $self->{flags} if exists $self->{flags};
- $self->{flags} = Bugzilla::Flag::match({ attach_id => $self->id,
- is_active => 1 });
+ $self->{flags} = Bugzilla::Flag::match({ 'attach_id' => $self->id });
return $self->{flags};
}
$flag_type->{'flags'} = Bugzilla::Flag::match(
{ 'bug_id' => $self->bug_id,
'type_id' => $flag_type->{'id'},
- 'target_type' => 'bug',
- 'is_active' => 1 });
+ 'target_type' => 'bug' });
}
$self->{'flag_types'} = $flag_types;
'component_id' => $self->{'component_id'} });
my $num_attachment_flags = Bugzilla::Flag::count(
{ 'target_type' => 'attachment',
- 'bug_id' => $self->bug_id,
- 'is_active' => 1 });
+ 'bug_id' => $self->bug_id });
$self->{'show_attachment_flags'} =
($num_attachment_flag_types || $num_attachment_flags);
# "flags" stores one record for each flag on each bug/attachment.
flags => {
FIELDS => [
- id => {TYPE => 'INT3', NOTNULL => 1,
+ id => {TYPE => 'MEDIUMSERIAL', NOTNULL => 1,
PRIMARYKEY => 1},
type_id => {TYPE => 'INT2', NOTNULL => 1},
status => {TYPE => 'char(1)', NOTNULL => 1},
modification_date => {TYPE => 'DATETIME'},
setter_id => {TYPE => 'INT3'},
requestee_id => {TYPE => 'INT3'},
- is_active => {TYPE => 'BOOLEAN', NOTNULL => 1,
- DEFAULT => 'TRUE'},
],
INDEXES => [
flags_bug_id_idx => [qw(bug_id attach_id)],
=cut
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");
=pod
my $flag = get($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.
grep($status eq $_, qw(X + - ?))
|| ThrowCodeError("flag_status_invalid",
my ($bug_id, $attach_id) = @_;
my $flags = match({ 'bug_id' => $bug_id,
- 'attach_id' => $attach_id,
- 'is_active' => 1 });
+ 'attach_id' => $attach_id });
my @summaries;
foreach my $flag (@$flags) {
my $summary = $flag->{'type'}->{'name'} . $flag->{'status'};
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)
WHERE bugs.bug_id = ?
- AND flags.is_active = 1
AND i.type_id IS NULL",
undef, $bug_id);
WHERE bugs.bug_id = ?
AND flags.bug_id = bugs.bug_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.component_id = e.component_id OR e.component_id IS NULL)",
undef, $bug_id);
sub create {
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 =
$flag->{target}->{attachment} ? $flag->{target}->{attachment}->{id}
: "NULL";
my $requestee_id = $flag->{'requestee'} ? $flag->{'requestee'}->id : "NULL";
- &::SendSQL("INSERT INTO flags (id, type_id,
- bug_id, attach_id,
- requestee_id, setter_id, status,
- creation_date, modification_date)
- VALUES ($flag->{'id'},
- $flag->{'type'}->{'id'},
+
+ &::SendSQL("INSERT INTO flags (type_id, bug_id, attach_id,
+ requestee_id, setter_id, status,
+ creation_date, modification_date)
+ VALUES ($flag->{'type'}->{'id'},
$flag->{'target'}->{'bug'}->{'id'},
$attach_id,
$requestee_id,
=item C<modify($cgi, $timestamp)>
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
SET setter_id = " . $setter->id . ",
requestee_id = NULL ,
status = '$status' ,
- modification_date = $timestamp ,
- is_active = 1
+ modification_date = $timestamp
WHERE id = $flag->{'id'}");
# If the status of the flag was "?", we have to notify
SET setter_id = " . $setter->id . ",
requestee_id = $requestee_id ,
status = '$status' ,
- modification_date = $timestamp ,
- is_active = 1
+ modification_date = $timestamp
WHERE id = $flag->{'id'}");
# Now update the flag object with its new values.
notify($flag, "request/email.txt.tmpl");
}
- # The user unset the flag; set is_active = 0
elsif ($status eq 'X') {
clear($flag->{'id'});
}
=item C<clear($id)>
-Deactivate a flag.
+Remove a flag from the DB.
=back
sub clear {
my ($id) = @_;
-
+ my $dbh = Bugzilla->dbh;
+
my $flag = get($id);
-
- &::PushGlobalSQLState();
- &::SendSQL("UPDATE flags SET is_active = 0 WHERE id = $id");
- &::PopGlobalSQLState();
+ $dbh->do('DELETE FROM flags WHERE id = ?', undef, $id);
# If we cancel a pending request, we have to notify the requester
# (if he wants to).
# We are only interested in flags the user tries to create.
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(
{ 'type_id' => $type_id,
'target_type' => $target->{'type'},
'bug_id' => $target->{'bug'}->{'id'},
'attach_id' => $target->{'attachment'} ?
- $target->{'attachment'}->{'id'} : undef,
- 'is_active' => 1 });
+ $target->{'attachment'}->{'id'} : undef });
# 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);
my $status = $cgi->param("flag_type-$type_id");
LEFT JOIN attachments ON flags.attach_id = attachments.attach_id
WHERE flags.attach_id = ?
AND flags.status = '?'
- AND flags.is_active = 1
AND attachments.isobsolete = 0",
undef, $attach_id);
elsif ($field eq 'requestee_id') { push(@criteria, "requestee_id = $value") }
elsif ($field eq 'setter_id') { push(@criteria, "setter_id = $value") }
elsif ($field eq 'status') { push(@criteria, "status = '$value'") }
- elsif ($field eq 'is_active') { push(@criteria, "is_active = $value") }
}
return @criteria;
=cut
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) = @_;
- return undef unless defined($exists);
+ return undef unless $id;
my $flag =
{
- exists => $exists ,
id => $id ,
type => Bugzilla::FlagType::get($type_id) ,
target => get_target($bug_id, $attach_id) ,
=item Kevin Benton <kevin.benton@amd.com>
+=item Frédéric Buclin <LpSolit@gmail.com>
+
=back
=cut
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))
WHERE flags.type_id IN ($ids)
- AND flags.is_active = 1
AND i.type_id IS NULL
");
Bugzilla::Flag::clear(&::FetchOneColumn()) while &::MoreSQLData();
WHERE flags.type_id IN ($ids)
AND flags.bug_id = bugs.bug_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.component_id = e.component_id OR e.component_id IS NULL)
");
# negative conditions (f.e. "flag isn't review+").
my $flags = "flags_$chartid";
push(@supptables, "LEFT JOIN flags AS $flags " .
- "ON bugs.bug_id = $flags.bug_id " .
- "AND $flags.is_active = 1");
+ "ON bugs.bug_id = $flags.bug_id ");
my $flagtypes = "flagtypes_$chartid";
push(@supptables, "LEFT JOIN flagtypes AS $flagtypes " .
"ON $flags.type_id = $flagtypes.id");
"^requestees.login_name," => sub {
my $flags = "flags_$chartid";
push(@supptables, "LEFT JOIN flags AS $flags " .
- "ON bugs.bug_id = $flags.bug_id " .
- "AND $flags.is_active = 1");
+ "ON bugs.bug_id = $flags.bug_id ");
push(@supptables, "LEFT JOIN profiles AS requestees_$chartid " .
"ON $flags.requestee_id = requestees_$chartid.userid");
$f = "requestees_$chartid.login_name";
"^setters.login_name," => sub {
my $flags = "flags_$chartid";
push(@supptables, "LEFT JOIN flags AS $flags " .
- "ON bugs.bug_id = $flags.bug_id " .
- "AND $flags.is_active = 1");
+ "ON bugs.bug_id = $flags.bug_id ");
push(@supptables, "LEFT JOIN profiles AS setters_$chartid " .
"ON $flags.setter_id = setters_$chartid.userid");
$f = "setters_$chartid.login_name";
{
$a->{'isviewable'} = isViewable($a->{'contenttype'});
- $a->{'flags'} = Bugzilla::Flag::match({ 'attach_id' => $a->{'attachid'},
- 'is_active' => 1 });
+ $a->{'flags'} = Bugzilla::Flag::match({ 'attach_id' => $a->{'attachid'} });
}
# Retrieve the bug summary (for displaying on screen) and assignee.
'component_id' => $component_id });
foreach my $flag_type (@$flag_types) {
$flag_type->{'flags'} = Bugzilla::Flag::match({ 'type_id' => $flag_type->{'id'},
- 'attach_id' => $attachment->id,
- 'is_active' => 1 });
+ 'attach_id' => $attachment->id });
}
$vars->{'flag_types'} = $flag_types;
$vars->{'any_flags_requesteeble'} = grep($_->{'is_requesteeble'}, @$flag_types);
$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
# membership and bless.
if ($dbh->bz_column_info("group_group_map", "isbless")) {
$dbh->bz_add_column('longdescs', 'comment_id',
{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
# differential change code *** A B O V E *** this comment.
#
AND (bugs.component_id = i.component_id
OR i.component_id IS NULL))
WHERE flags.type_id = ?
- AND flags.is_active = 1
AND i.type_id IS NULL',
undef, $id);
foreach my $flag_id (@$flag_ids) {
INNER JOIN flagexclusions AS e
ON flags.type_id = e.type_id
WHERE flags.type_id = ?
- AND flags.is_active = 1
AND (bugs.product_id = e.product_id
OR e.product_id IS NULL)
AND (bugs.component_id = e.component_id
# check if we need confirmation to delete:
- my $count = Bugzilla::Flag::count({ 'type_id' => $id,
- 'is_active' => 1 });
+ my $count = Bugzilla::Flag::count({ 'type_id' => $id });
if ($count > 0) {
$vars->{'flag_type'} = Bugzilla::FlagType::get($id);
'SELECT COUNT(*) FROM email_setting WHERE user_id = ?',
undef, $otherUserID);
$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);
$vars->{'flags'}{'setter'} = $dbh->selectrow_array(
'SELECT COUNT(*) FROM flags WHERE setter_id = ?',
return $err;
}
- my ($fid) = $dbh->selectrow_array("SELECT MAX(id) FROM flags") || 0;
$dbh->do("INSERT INTO flags
- (id, type_id, status, bug_id, attach_id, creation_date,
- setter_id, requestee_id, is_active)
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", undef,
- ++$fid, $ftypeid, $status, $bugid, $attachid, $timestamp,
- $setter_id, $requestee_id, 1
- );
+ (type_id, status, bug_id, attach_id, creation_date,
+ setter_id, requestee_id)
+ VALUES (?, ?, ?, ?, ?, ?, ?)", undef,
+ ($ftypeid, $status, $bugid, $attachid, $timestamp,
+ $setter_id, $requestee_id));
}
else {
$err = "Dropping unknown $type flag: $name\n";
(Param('useqacontact') ? "OR
(bugs.qa_contact = $userid))" : ")");
- # Non-deleted flags only
- $query .= " AND flags.is_active = 1 ";
-
# Limit query to pending requests.
$query .= " AND flags.status = '?' " unless $status;