]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 413258: When setting a flag on an attachment on bug creation, an incorrect messag...
authorlpsolit%gmail.com <>
Mon, 21 Jan 2008 04:12:50 +0000 (04:12 +0000)
committerlpsolit%gmail.com <>
Mon, 21 Jan 2008 04:12:50 +0000 (04:12 +0000)
Bugzilla/Flag.pm

index adc92cfd4404e9d5ddc210d47a88f437f4d22a6b..9dc6a2ef5fc9e8a65a83b6416311e6d6f0020e2f 100644 (file)
@@ -963,10 +963,9 @@ sub FormToNewFlags {
 
     return () unless scalar(@type_ids);
 
-    # Get a list of active flag types available for this target.
+    # Get a list of active flag types available for this product/component.
     my $flag_types = Bugzilla::FlagType::match(
-        { 'target_type'  => $attachment ? 'attachment' : 'bug',
-          'product_id'   => $bug->{'product_id'},
+        { 'product_id'   => $bug->{'product_id'},
           'component_id' => $bug->{'component_id'},
           'is_active'    => 1 });
 
@@ -982,6 +981,10 @@ sub FormToNewFlags {
     foreach my $flag_type (@$flag_types) {
         my $type_id = $flag_type->id;
 
+        # Bug flags are only valid for bugs, and attachment flags are
+        # only valid for attachments. So don't mix both.
+        next unless ($flag_type->target_type eq 'bug' xor $attachment);
+
         # We are only interested in flags the user tries to create.
         next unless scalar(grep { $_ == $type_id } @type_ids);