summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2006-04-15 01:50:39 +0200
committerlpsolit%gmail.com <>2006-04-15 01:50:39 +0200
commit344149d0e639267412ca0e2ccd95c2872e9350d9 (patch)
tree27b64e7e1c6e35367803bce5a35f7addfc1337c6 /Bugzilla
parentbd0e09be136d808154320d61bf2725e2324c2243 (diff)
downloadbugzilla-344149d0e639267412ca0e2ccd95c2872e9350d9.tar.gz
bugzilla-344149d0e639267412ca0e2ccd95c2872e9350d9.tar.xz
Bug 322285: Cancelling a flag should remove it completely from the DB - Patch by Frédéric Buclin <LpSolit@gmail.com> r/a=myk
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Attachment.pm3
-rwxr-xr-xBugzilla/Bug.pm6
-rw-r--r--Bugzilla/DB/Schema.pm4
-rw-r--r--Bugzilla/Flag.pm65
-rw-r--r--Bugzilla/FlagType.pm2
-rw-r--r--Bugzilla/Search.pm9
6 files changed, 27 insertions, 62 deletions
diff --git a/Bugzilla/Attachment.pm b/Bugzilla/Attachment.pm
index 8b0203924..350adfd72 100644
--- a/Bugzilla/Attachment.pm
+++ b/Bugzilla/Attachment.pm
@@ -373,8 +373,7 @@ sub flags {
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};
}
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index 445e13ec6..c0063aa14 100755
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -429,8 +429,7 @@ sub flag_types {
$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;
@@ -515,8 +514,7 @@ sub show_attachment_flags {
'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);
diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm
index 32f09a099..16b5320d6 100644
--- a/Bugzilla/DB/Schema.pm
+++ b/Bugzilla/DB/Schema.pm
@@ -375,7 +375,7 @@ use constant ABSTRACT_SCHEMA => {
# "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},
@@ -385,8 +385,6 @@ use constant ABSTRACT_SCHEMA => {
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)],
diff --git a/Bugzilla/Flag.pm b/Bugzilla/Flag.pm
index a3929a970..97d8e8c7c 100644
--- a/Bugzilla/Flag.pm
+++ b/Bugzilla/Flag.pm
@@ -94,7 +94,7 @@ database. B<Used by get, match, sqlify_criteria and perlify_record>
=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
@@ -284,11 +284,6 @@ sub validate {
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",
@@ -398,8 +393,7 @@ sub snapshot {
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'};
@@ -466,7 +460,6 @@ sub process {
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);
@@ -478,7 +471,6 @@ sub process {
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);
@@ -529,22 +521,15 @@ Creates a flag record in the database.
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,
@@ -597,9 +582,6 @@ sub migrate {
=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
@@ -681,8 +663,7 @@ sub modify {
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
@@ -722,8 +703,7 @@ sub modify {
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.
@@ -739,7 +719,6 @@ sub modify {
notify($flag, "request/email.txt.tmpl");
}
- # The user unset the flag; set is_active = 0
elsif ($status eq 'X') {
clear($flag->{'id'});
}
@@ -756,7 +735,7 @@ sub modify {
=item C<clear($id)>
-Deactivate a flag.
+Remove a flag from the DB.
=back
@@ -764,12 +743,10 @@ Deactivate a flag.
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).
@@ -834,17 +811,16 @@ sub FormToNewFlags {
# 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");
@@ -1032,7 +1008,6 @@ sub CancelRequests {
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);
@@ -1094,7 +1069,6 @@ sub sqlify_criteria {
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;
@@ -1115,14 +1089,13 @@ Converts a row from the database into a Perl record.
=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) ,
@@ -1153,6 +1126,8 @@ sub perlify_record {
=item Kevin Benton <kevin.benton@amd.com>
+=item Frédéric Buclin <LpSolit@gmail.com>
+
=back
=cut
diff --git a/Bugzilla/FlagType.pm b/Bugzilla/FlagType.pm
index 950aeea9a..b18c4a2de 100644
--- a/Bugzilla/FlagType.pm
+++ b/Bugzilla/FlagType.pm
@@ -474,7 +474,6 @@ sub normalize {
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();
@@ -485,7 +484,6 @@ sub normalize {
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)
");
diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm
index 22ab90f56..960ff336d 100644
--- a/Bugzilla/Search.pm
+++ b/Bugzilla/Search.pm
@@ -843,8 +843,7 @@ sub init {
# 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");
@@ -874,8 +873,7 @@ sub init {
"^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";
@@ -883,8 +881,7 @@ sub init {
"^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";