summaryrefslogtreecommitdiffstats
path: root/Bugzilla/WebService/Bug.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla/WebService/Bug.pm')
-rw-r--r--Bugzilla/WebService/Bug.pm33
1 files changed, 23 insertions, 10 deletions
diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm
index cc40259f8..a922c2bf0 100644
--- a/Bugzilla/WebService/Bug.pm
+++ b/Bugzilla/WebService/Bug.pm
@@ -681,7 +681,7 @@ sub update {
foreach my $bug (@bugs) {
$bug->set_all(\%values);
if ($flags) {
- my ($old_flags, $new_flags) = extract_flags($flags, $bug);
+ my ($old_flags, $new_flags) = extract_flags($flags, $bug->flag_types, $bug->flags);
$bug->set_flags($old_flags, $new_flags);
}
}
@@ -747,6 +747,23 @@ sub create {
$params = Bugzilla::Bug::map_fields($params);
my $flags = delete $params->{flags};
+ # Set bug flags
+ if ($flags) {
+ my $product = Bugzilla::Product->check($params->{product});
+ my $component = Bugzilla::Component->check({
+ product => $product,
+ name => $params->{component}
+ });
+ my $flag_types = Bugzilla::FlagType::match({
+ product_id => $product->id,
+ component_id => $component->id,
+ is_active => 1,
+ });
+
+ my(undef, $new_flags) = extract_flags($flags, $flag_types);
+
+ $params->{flags} = $new_flags;
+ }
# We start a nested transaction in case flag setting fails
# we want the bug creation to roll back as well.
@@ -754,13 +771,6 @@ sub create {
my $bug = Bugzilla::Bug->create($params);
- # Set bug flags
- if ($flags) {
- my ($flags, $new_flags) = extract_flags($flags, $bug);
- $bug->set_flags($flags, $new_flags);
- $bug->update($bug->creation_ts);
- }
-
$dbh->bz_commit_transaction();
$bug->send_changes();
@@ -853,7 +863,10 @@ sub add_attachment {
});
if ($flags) {
- my ($old_flags, $new_flags) = extract_flags($flags, $bug, $attachment);
+ my ($old_flags, $new_flags) = extract_flags($flags,
+ $attachment->flag_types,
+ $attachment->flags);
+
$attachment->set_flags($old_flags, $new_flags);
}
@@ -938,7 +951,7 @@ sub update_attachment {
# Update the values
foreach my $attachment (@attachments) {
my ($update_flags, $new_flags) = $flags
- ? extract_flags($flags, $attachment->bug, $attachment)
+ ? extract_flags($flags, $attachment->flag_types, $attachment->flags)
: ([], []);
if ($attachment->validate_can_edit) {
$attachment->set_all($params);