From 19e01dc112cd0f89211111a4b54ff90629b1a300 Mon Sep 17 00:00:00 2001 From: vfilippov Date: Wed, 26 Oct 2011 11:57:33 +0000 Subject: [PATCH] Bug 54779 - Do not crash with a code error, but warn user in the case of different product case git-svn-id: svn://svn.office.custis.ru/3rdparty/bugzilla.org/trunk@1448 6955db30-a419-402b-8a0d-67ecbb4d7f56 --- Bugzilla/User.pm | 22 +++++++++++-------- .../en/default/global/user-error.html.tmpl | 4 ++++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm index 62bfa63d6..95f1ab9cf 100644 --- a/Bugzilla/User.pm +++ b/Bugzilla/User.pm @@ -862,6 +862,10 @@ sub can_enter_product { elsif (!@{$product->versions}) { ThrowUserError ('missing_version', { product => $product }); } + # It could have the name in a different case :) + elsif (!blessed($input) && $product->name ne $input) { + ThrowUserError ('product_invalid_case', { product => $input, suggested => $product->name }); + } die "can_enter_product reached an unreachable location."; } @@ -874,15 +878,15 @@ sub get_enterable_products { return $self->{enterable_products}; } - # All products which the user has "Entry" access to. - my @enterable_ids = @{$dbh->selectcol_arrayref( - 'SELECT products.id FROM products - LEFT JOIN group_control_map - ON group_control_map.product_id = products.id - AND group_control_map.entry != 0 - AND group_id NOT IN (' . $self->groups_as_string . ') - WHERE group_id IS NULL - AND products.isactive = 1') || []}; + # All products which the user has "Entry" access to. + my @enterable_ids = @{$dbh->selectcol_arrayref( + 'SELECT products.id FROM products + LEFT JOIN group_control_map + ON group_control_map.product_id = products.id + AND group_control_map.entry != 0 + AND group_id NOT IN (' . $self->groups_as_string . ') + WHERE group_id IS NULL + AND products.isactive = 1') || []}; if (@enterable_ids) { # And all of these products must have at least one component diff --git a/template/en/default/global/user-error.html.tmpl b/template/en/default/global/user-error.html.tmpl index b2eaf201e..bb4c3eeef 100644 --- a/template/en/default/global/user-error.html.tmpl +++ b/template/en/default/global/user-error.html.tmpl @@ -1716,6 +1716,10 @@ I could not figure out what you wanted to do. [% END %] + [% ELSIF error == "product_invalid_case" %] + You have requested the product name "[% product | html %]", did you mean + "[% suggested | html %]"? + [% ELSIF error == "incorrect_field_values" %] [% IF bug_id %] [% terms.Bug %] [%+ bug_id %]: