]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 714446: Product.create default behavior is broken and inconsistent with POD
authorFrédéric Buclin <LpSolit@gmail.com>
Tue, 31 Jan 2012 12:04:49 +0000 (13:04 +0100)
committerFrédéric Buclin <LpSolit@gmail.com>
Tue, 31 Jan 2012 12:04:49 +0000 (13:04 +0100)
r=dkl a=LpSolit

Bugzilla/WebService/Product.pm

index 3414be4fd53a02af51e2cb0a8461f1b82f2b0b8c..3cd0d0a6c04db8e63e3c7cce21ccd30d7b6ecb1b 100644 (file)
@@ -34,6 +34,11 @@ use constant READ_ONLY => qw(
     get_selectable_products
 );
 
+use constant FIELD_MAP => {
+    has_unconfirmed => 'allows_unconfirmed',
+    is_open         => 'isactive',
+};
+
 ##################################################
 # Add aliases here for method name compatibility #
 ##################################################
@@ -105,16 +110,22 @@ sub create {
                                             action => "add",
                                             object => "products"});
     # Create product
-    my $product = Bugzilla::Product->create({
-        allows_unconfirmed => $params->{has_unconfirmed},
-        classification     => $params->{classification},
-        name               => $params->{name},
-        description        => $params->{description},
-        version            => $params->{version},
-        defaultmilestone   => $params->{default_milestone},
-        isactive           => $params->{is_open},
-        create_series      => $params->{create_series}
-    });
+    my $args = {
+        name             => $params->{name},
+        description      => $params->{description},
+        version          => $params->{version},
+        defaultmilestone => $params->{default_milestone},
+        # create_series has no default value.
+        create_series    => defined $params->{create_series} ?
+                              $params->{create_series} : 1
+    };
+    foreach my $field (qw(has_unconfirmed is_open classification)) {
+        if (defined $params->{$field}) {
+            my $name = FIELD_MAP->{$field} || $field;
+            $args->{$name} = $params->{$field};
+        }
+    }
+    my $product = Bugzilla::Product->create($args);
     return { id => $self->type('int', $product->id) };
 }
 
@@ -460,6 +471,7 @@ B<Required> C<string> The default version for this product.
 =item C<has_unconfirmed> 
 
 C<boolean> Allow the UNCONFIRMED status to be set on bugs in this product.
+Default: true.
 
 =item C<classification>
 
@@ -467,17 +479,17 @@ C<string> The name of the Classification which contains this product.
 
 =item C<default_milestone> 
 
-C<string> The default milestone for this product.
+C<string> The default milestone for this product. Default: '---'.
 
 =item C<is_open> 
 
 C<boolean> True if the product is currently allowing bugs to be entered
-into it.
+into it. Default: true.
 
 =item C<create_series>
 
 C<boolean> True if you want series for New Charts to be created for this
-new product.
+new product. Default: true.
 
 =back
 
@@ -489,6 +501,10 @@ A hash with one element, id. This is the id of the newly-filed product.
 
 =over
 
+=item 51 (Classification does not exist)
+
+You must specify an existing classification name.
+
 =item 700 (Product blank name)
 
 You must specify a non-blank name for this product.
@@ -511,10 +527,6 @@ You must specify a description for this product.
 
 You must specify a version for this product.
 
-=item 705 (Product must define a defaut milestone)
-
-You must define a default milestone.
-
 =back
 
 =back