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
git-svn-id: svn://10.0.0.236/trunk@175743 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -468,19 +468,30 @@ sub CanEnterProduct {
|
||||
}
|
||||
|
||||
# Check if the product is open for new bugs and has
|
||||
# at least one component.
|
||||
my $allow_new_bugs =
|
||||
$dbh->selectrow_array("SELECT CASE WHEN disallownew = 0 THEN 1 ELSE 0 END
|
||||
FROM products INNER JOIN components
|
||||
ON components.product_id = products.id
|
||||
WHERE products.name = ? " .
|
||||
$dbh->sql_limit(1),
|
||||
undef, $productname);
|
||||
# at least one component and has at least one version.
|
||||
my ($allow_new_bugs, $has_version) =
|
||||
$dbh->selectrow_array('SELECT CASE WHEN disallownew = 0 THEN 1 ELSE 0 END, ' .
|
||||
'versions.value IS NOT NULL ' .
|
||||
'FROM products INNER JOIN components ' .
|
||||
'ON components.product_id = products.id ' .
|
||||
'LEFT JOIN versions ' .
|
||||
'ON versions.product_id = products.id ' .
|
||||
'WHERE products.name = ? ' .
|
||||
$dbh->sql_limit(1), undef, $productname);
|
||||
|
||||
# Return 1 if the user can enter bugs into that product;
|
||||
# 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
|
||||
@@ -491,17 +502,23 @@ sub CanEnterProductOrWarn {
|
||||
if (!defined($product)) {
|
||||
ThrowUserError("no_products");
|
||||
}
|
||||
my $status = CanEnterProduct($product, 1);
|
||||
my ($allow_new_bugs, $has_version) = CanEnterProduct($product, 1);
|
||||
trick_taint($product);
|
||||
|
||||
if (!defined($status)) {
|
||||
ThrowUserError("no_components", { product => $product});
|
||||
} elsif (!$status) {
|
||||
if (!defined $allow_new_bugs) {
|
||||
ThrowUserError("missing_version_or_component",
|
||||
{ product => $product,
|
||||
missing_item => 'Component' })
|
||||
} elsif (!$allow_new_bugs) {
|
||||
ThrowUserError("product_disabled", { product => $product});
|
||||
} elsif ($status < 0) {
|
||||
} elsif ($allow_new_bugs < 0) {
|
||||
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 {
|
||||
|
||||
@@ -746,7 +746,21 @@
|
||||
[% ELSIF error == "missing_category" %]
|
||||
[% title = "Missing Category" %]
|
||||
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" %]
|
||||
[% title = "Missing Content-Type" %]
|
||||
You asked [% terms.Bugzilla %] to auto-detect the content type, but
|
||||
@@ -825,18 +839,6 @@
|
||||
You cannot change the component for a list of [% terms.bugs %] covering more than
|
||||
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" %]
|
||||
[% title = "Cannot Find Duplicate Statistics" %]
|
||||
There are no duplicate statistics for today ([% today FILTER html %])
|
||||
|
||||
Reference in New Issue
Block a user