]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 223570: Creating a bug in a product with no versions results in internal error...
authorlpsolit%gmail.com <>
Thu, 7 Jul 2005 21:08:41 +0000 (21:08 +0000)
committerlpsolit%gmail.com <>
Thu, 7 Jul 2005 21:08:41 +0000 (21:08 +0000)
globals.pl
template/en/default/global/user-error.html.tmpl

index e46766c5d827b9f0fb0dd3f632fb0ff3818f7b55..517ed1827cae4a275c580f3f51f3e1358d6ecaaf 100644 (file)
@@ -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 {
index 2696ede15e0af33992eb33df2746067c5bae6103..20d8371f47b3aefd393f4f8d7c3d4b89f9ce6980 100644 (file)
   [% 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
     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 %])