From: lpsolit%gmail.com <> Date: Sun, 7 Jan 2007 03:55:28 +0000 (+0000) Subject: Bug 365403: Prevent tags from overwriting existing saved searches - Patch by FrÃ... X-Git-Tag: bugzilla-2.23.4~79 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b553417d4f0c6badbabb452024536b493ebb987e;p=thirdparty%2Fbugzilla.git Bug 365403: Prevent tags from overwriting existing saved searches - Patch by Frédéric Buclin r=bkor a=justdave --- diff --git a/buglist.cgi b/buglist.cgi index e32a17dda5..7181c21993 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 244a7f48ac..aebaf11781 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 [% name FILTER html %] is already used by another + saved search. You first have to + delete 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"} %]