Commit 4e10a0b8 authored by Frédéric Buclin's avatar Frédéric Buclin

Bug 714446: Product.create default behavior is broken and inconsistent with POD

r=dkl a=LpSolit
parent e5cdfebc
...@@ -34,6 +34,11 @@ use constant MAPPED_RETURNS => { ...@@ -34,6 +34,11 @@ use constant MAPPED_RETURNS => {
isactive => 'is_open', isactive => 'is_open',
}; };
use constant FIELD_MAP => {
has_unconfirmed => 'allows_unconfirmed',
is_open => 'isactive',
};
################################################## ##################################################
# Add aliases here for method name compatibility # # Add aliases here for method name compatibility #
################################################## ##################################################
...@@ -105,16 +110,22 @@ sub create { ...@@ -105,16 +110,22 @@ sub create {
action => "add", action => "add",
object => "products"}); object => "products"});
# Create product # Create product
my $product = Bugzilla::Product->create({ my $args = {
allows_unconfirmed => $params->{has_unconfirmed}, name => $params->{name},
classification => $params->{classification}, description => $params->{description},
name => $params->{name}, version => $params->{version},
description => $params->{description}, defaultmilestone => $params->{default_milestone},
version => $params->{version}, # create_series has no default value.
defaultmilestone => $params->{default_milestone}, create_series => defined $params->{create_series} ?
isactive => $params->{is_open}, $params->{create_series} : 1
create_series => $params->{create_series} };
}); 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) }; return { id => $self->type('int', $product->id) };
} }
...@@ -516,6 +527,7 @@ B<Required> C<string> The default version for this product. ...@@ -516,6 +527,7 @@ B<Required> C<string> The default version for this product.
=item C<has_unconfirmed> =item C<has_unconfirmed>
C<boolean> Allow the UNCONFIRMED status to be set on bugs in this product. C<boolean> Allow the UNCONFIRMED status to be set on bugs in this product.
Default: true.
=item C<classification> =item C<classification>
...@@ -523,17 +535,17 @@ C<string> The name of the Classification which contains this product. ...@@ -523,17 +535,17 @@ C<string> The name of the Classification which contains this product.
=item C<default_milestone> =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> =item C<is_open>
C<boolean> True if the product is currently allowing bugs to be entered C<boolean> True if the product is currently allowing bugs to be entered
into it. into it. Default: true.
=item C<create_series> =item C<create_series>
C<boolean> True if you want series for New Charts to be created for this C<boolean> True if you want series for New Charts to be created for this
new product. new product. Default: true.
=back =back
...@@ -545,6 +557,10 @@ A hash with one element, id. This is the id of the newly-filed product. ...@@ -545,6 +557,10 @@ A hash with one element, id. This is the id of the newly-filed product.
=over =over
=item 51 (Classification does not exist)
You must specify an existing classification name.
=item 700 (Product blank name) =item 700 (Product blank name)
You must specify a non-blank name for this product. You must specify a non-blank name for this product.
...@@ -567,10 +583,6 @@ You must specify a description for this product. ...@@ -567,10 +583,6 @@ You must specify a description for this product.
You must specify a version 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
=back =back
...@@ -685,7 +697,35 @@ Here's an example of what a return value might look like: ...@@ -685,7 +697,35 @@ Here's an example of what a return value might look like:
=item B<Errors> =item B<Errors>
The same as L</create>. =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 =back
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment