summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbuglist.cgi19
-rw-r--r--template/en/default/global/user-error.html.tmpl8
2 files changed, 22 insertions, 5 deletions
diff --git a/buglist.cgi b/buglist.cgi
index e32a17dda..7181c2199 100755
--- a/buglist.cgi
+++ b/buglist.cgi
@@ -212,10 +212,11 @@ sub DiffDate {
}
sub LookupNamedQuery {
- my ($name, $sharer_id, $query_type) = @_;
+ my ($name, $sharer_id, $query_type, $throw_error) = @_;
my $user = Bugzilla->login(LOGIN_REQUIRED);
my $dbh = Bugzilla->dbh;
my $owner_id;
+ $throw_error = 1 unless defined $throw_error;
# $name and $sharer_id are safe -- we only use them below in SELECT
# placeholders and then in error messages (which are always HTML-filtered).
@@ -243,9 +244,11 @@ sub LookupNamedQuery {
WHERE userid = ? AND name = ?
$extra",
undef, @args);
- defined($result)
- || ThrowUserError("missing_query", {'queryname' => $name,
- 'sharer_id' => $sharer_id});
+ if (!defined($result)) {
+ return 0 unless $throw_error;
+ ThrowUserError("missing_query", {'queryname' => $name,
+ 'sharer_id' => $sharer_id});
+ }
if ($sharer_id) {
my $group = $dbh->selectrow_array('SELECT group_id
@@ -499,7 +502,13 @@ elsif (($cgi->param('cmdtype') eq "doit") && defined $cgi->param('remtype')) {
}
my %bug_ids;
- unless ($query_name) {
+ if ($query_name) {
+ # Make sure this name is not already in use by a normal saved search.
+ if (LookupNamedQuery($query_name, undef, QUERY_LIST, !THROW_ERROR)) {
+ ThrowUserError('query_name_exists', {'name' => $query_name});
+ }
+ }
+ else {
# No new query name has been given. We retrieve bug IDs
# currently set in the selected saved search.
$query_name = $cgi->param('oldqueryname');
diff --git a/template/en/default/global/user-error.html.tmpl b/template/en/default/global/user-error.html.tmpl
index 244a7f48a..aebaf1178 100644
--- a/template/en/default/global/user-error.html.tmpl
+++ b/template/en/default/global/user-error.html.tmpl
@@ -1249,6 +1249,14 @@
No product specified when trying to edit components, milestones, versions
or product.
+ [% ELSIF error == "query_name_exists" %]
+ [% title = "Search Name Already In Use" %]
+ The name <em>[% name FILTER html %]</em> is already used by another
+ saved search. You first have to
+ <a href="buglist.cgi?cmdtype=dorem&amp;remaction=forget&amp;namedcmd=
+ [%- name FILTER url_quote %]">delete</a> it if you really want to use
+ this name.
+
[% ELSIF error == "query_name_missing" %]
[% title = "No Search Name Specified" %]
[% docslinks = {'list.html' => "About $terms.bug lists"} %]