summaryrefslogtreecommitdiffstats
path: root/globals.pl
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2005-07-07 23:08:41 +0200
committerlpsolit%gmail.com <>2005-07-07 23:08:41 +0200
commit44119f9d89be2b5d25351637c35614ea9a180c69 (patch)
treefb458891e0f3388c02f29a192337cc46395900c2 /globals.pl
parent73270363b7dabda4406b5ab638ead98a951eebeb (diff)
downloadbugzilla-44119f9d89be2b5d25351637c35614ea9a180c69.tar.gz
bugzilla-44119f9d89be2b5d25351637c35614ea9a180c69.tar.xz
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
Diffstat (limited to 'globals.pl')
-rw-r--r--globals.pl55
1 files changed, 36 insertions, 19 deletions
diff --git a/globals.pl b/globals.pl
index e46766c5d..517ed1827 100644
--- a/globals.pl
+++ b/globals.pl
@@ -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);
-
- # 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;
+ # 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);
+
+
+ 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 {