]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1543741 - Blocklist requests getting filed as 'defect' instead of 'task' because...
authorKohei Yoshino <kohei.yoshino@gmail.com>
Tue, 23 Apr 2019 22:26:18 +0000 (18:26 -0400)
committerGitHub <noreply@github.com>
Tue, 23 Apr 2019 22:26:18 +0000 (18:26 -0400)
Bugzilla/Bug.pm

index ac96a7729d9e14db9b87d0663c88ee94e86791ac..25cbadb288c6e932cf86d63db892009e936b4429 100644 (file)
@@ -900,13 +900,29 @@ sub create {
   $dbh->bz_start_transaction();
 
   # These fields have default values which we can use if they are undefined.
-  $params->{bug_type} = Bugzilla->params->{default_bug_type}
-    unless defined $params->{bug_type};
   $params->{bug_severity} = Bugzilla->params->{defaultseverity}
     unless defined $params->{bug_severity};
   $params->{priority} = Bugzilla->params->{defaultpriority}
     unless defined $params->{priority};
 
+  # Bug type can be defined at the component, product or instance level
+  unless (defined $params->{bug_type}) {
+    my $product
+      = (defined $params->{product})
+      ? Bugzilla::Product->new({name => $params->{product}, cache => 1})
+      : undef;
+    my $component
+      = ($product && defined $params->{component})
+      ? Bugzilla::Component->new({name => $params->{component}, product => $product, cache => 1})
+      : undef;
+    # The component's default bug type inherits or overrides the default bug
+    # type of the product or instance
+    $params->{bug_type}
+      = ($component)
+      ? $component->default_bug_type
+      : Bugzilla->params->{default_bug_type};
+  }
+
   # BMO - per-product hw/os defaults
   if (!defined $params->{rep_platform} || !defined $params->{op_sys}) {
     if (my $product