Commit 44119f9d authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 223570: Creating a bug in a product with no versions results in internal…

Bug 223570: Creating a bug in a product with no versions results in internal error - Patch by A. Karl Kornel <karl@kornel.name> r=LpSolit a=justdave
parent 73270363
...@@ -468,19 +468,30 @@ sub CanEnterProduct { ...@@ -468,19 +468,30 @@ sub CanEnterProduct {
} }
# Check if the product is open for new bugs and has # Check if the product is open for new bugs and has
# at least one component. # at least one component and has at least one version.
my $allow_new_bugs = my ($allow_new_bugs, $has_version) =
$dbh->selectrow_array("SELECT CASE WHEN disallownew = 0 THEN 1 ELSE 0 END $dbh->selectrow_array('SELECT CASE WHEN disallownew = 0 THEN 1 ELSE 0 END, ' .
FROM products INNER JOIN components 'versions.value IS NOT NULL ' .
ON components.product_id = products.id 'FROM products INNER JOIN components ' .
WHERE products.name = ? " . 'ON components.product_id = products.id ' .
$dbh->sql_limit(1), 'LEFT JOIN versions ' .
undef, $productname); 'ON versions.product_id = products.id ' .
'WHERE products.name = ? ' .
# Return 1 if the user can enter bugs into that product; $dbh->sql_limit(1), undef, $productname);
# return 0 if the product is closed for new bug entry;
# return undef if the product has no component.
return $allow_new_bugs; if (defined $verbose) {
# Return (undef, undef) if the product has no components,
# Return (?, 0) if the product has no versions,
# Return (0, ?) if the product is closed for new bug entry,
# Return (1, 1) if the user can enter bugs into the product,
return ($allow_new_bugs, $has_version);
} else {
# Return undef if the product has no components
# Return 0 if the product has no versions, or is closed for bug entry
# Return 1 if the user can enter bugs into the product
return ($allow_new_bugs && $has_version);
}
} }
# Call CanEnterProduct() and display an error message # Call CanEnterProduct() and display an error message
...@@ -491,17 +502,23 @@ sub CanEnterProductOrWarn { ...@@ -491,17 +502,23 @@ sub CanEnterProductOrWarn {
if (!defined($product)) { if (!defined($product)) {
ThrowUserError("no_products"); ThrowUserError("no_products");
} }
my $status = CanEnterProduct($product, 1); my ($allow_new_bugs, $has_version) = CanEnterProduct($product, 1);
trick_taint($product); trick_taint($product);
if (!defined($status)) { if (!defined $allow_new_bugs) {
ThrowUserError("no_components", { product => $product}); ThrowUserError("missing_version_or_component",
} elsif (!$status) { { product => $product,
missing_item => 'Component' })
} elsif (!$allow_new_bugs) {
ThrowUserError("product_disabled", { product => $product}); ThrowUserError("product_disabled", { product => $product});
} elsif ($status < 0) { } elsif ($allow_new_bugs < 0) {
ThrowUserError("entry_access_denied", { product => $product}); ThrowUserError("entry_access_denied", { product => $product});
} elsif (!$has_version) {
ThrowUserError("missing_version_or_component",
{ product => $product,
missing_item => 'Version' });
} }
return $status; return 1;
} }
sub GetEnterableProducts { sub GetEnterableProducts {
......
...@@ -746,7 +746,21 @@ ...@@ -746,7 +746,21 @@
[% ELSIF error == "missing_category" %] [% ELSIF error == "missing_category" %]
[% title = "Missing Category" %] [% title = "Missing Category" %]
You did not specify a category for this series. You did not specify a category for this series.
[% ELSIF error == "missing_version_or_component" %]
[% title = BLOCK %]Missing [% missing_item FILTER none %][% END %]
Sorry; there needs to be at least one [% missing_item FILTER lower %]
associated with the product <em>[% product FILTER html %]</em> in order to
create a new [% terms.bug %].
[% IF UserInGroup("editcomponents") %]
<a href="edit[% missing_item FILTER lower %]s.cgi?product=
[%- product FILTER url_quote %]">Create a new
[%+ missing_item FILTER lower %]</a>.
[% ELSE %]
Please contact [% Param("maintainer") %], giving the name of
the product in which you tried to create a new [% terms.bug %].
[% END %]
[% ELSIF error == "missing_content_type" %] [% ELSIF error == "missing_content_type" %]
[% title = "Missing Content-Type" %] [% title = "Missing Content-Type" %]
You asked [% terms.Bugzilla %] to auto-detect the content type, but You asked [% terms.Bugzilla %] to auto-detect the content type, but
...@@ -825,18 +839,6 @@ ...@@ -825,18 +839,6 @@
You cannot change the component for a list of [% terms.bugs %] covering more than You cannot change the component for a list of [% terms.bugs %] covering more than
one product. one product.
[% ELSIF error == "no_components" %]
[% title = "No Components" %]
Sorry; there needs to be at least one component for this product in order
to create a new [% terms.bug %].
[% IF UserInGroup("editcomponents") %]
<a href="editcomponents.cgi?product=[% product FILTER url_quote %]">Create
a new component</a>.
[% ELSE %]
Please contact [% Param("maintainer") %], giving the name of
the product in which you tried to create a new [% terms.bug %].
[% END %]
[% ELSIF error == "no_dupe_stats" %] [% ELSIF error == "no_dupe_stats" %]
[% title = "Cannot Find Duplicate Statistics" %] [% title = "Cannot Find Duplicate Statistics" %]
There are no duplicate statistics for today ([% today FILTER html %]) There are no duplicate statistics for today ([% today FILTER html %])
......
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