From 4e10a0b85df1228abc0b59ff7b4e830cb28ee093 Mon Sep 17 00:00:00 2001 From: Frédéric Buclin Date: Tue, 31 Jan 2012 13:00:11 +0100 Subject: Bug 714446: Product.create default behavior is broken and inconsistent with POD r=dkl a=LpSolit --- Bugzilla/WebService/Product.pm | 76 ++++++++++++++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 18 deletions(-) (limited to 'Bugzilla') diff --git a/Bugzilla/WebService/Product.pm b/Bugzilla/WebService/Product.pm index 0ca182142..7d4ddb147 100644 --- a/Bugzilla/WebService/Product.pm +++ b/Bugzilla/WebService/Product.pm @@ -34,6 +34,11 @@ use constant MAPPED_RETURNS => { isactive => 'is_open', }; +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) }; } @@ -516,6 +527,7 @@ B C The default version for this product. =item C C Allow the UNCONFIRMED status to be set on bugs in this product. +Default: true. =item C @@ -523,17 +535,17 @@ C The name of the Classification which contains this product. =item C -C The default milestone for this product. +C The default milestone for this product. Default '---'. =item C C True if the product is currently allowing bugs to be entered -into it. +into it. Default: true. =item C C True if you want series for New Charts to be created for this -new product. +new product. Default: true. =back @@ -545,6 +557,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. @@ -567,10 +583,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 @@ -685,7 +697,35 @@ Here's an example of what a return value might look like: =item B -The same as L. +=over + +=item 700 (Product blank name) + +You must specify a non-blank name for this product. + +=item 701 (Product name too long) + +The name specified for this product was longer than the maximum +allowed length. + +=item 702 (Product name already exists) + +You specified the name of a product that already exists. +(Product names must be globally unique in Bugzilla.) + +=item 703 (Product must have description) + +You must specify a description for this product. + +=item 704 (Product must have version) + +You must specify a version for this product. + +=item 705 (Product must define a default milestone) + +You must define a default milestone. + +=back =back -- cgit v1.2.3-24-g4f1b