Commit b553417d authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 365403: Prevent tags from overwriting existing saved searches - Patch by…

Bug 365403: Prevent tags from overwriting existing saved searches - Patch by Fré©ric Buclin <LpSolit@gmail.com> r=bkor a=justdave
parent a397877d
...@@ -212,10 +212,11 @@ sub DiffDate { ...@@ -212,10 +212,11 @@ sub DiffDate {
} }
sub LookupNamedQuery { sub LookupNamedQuery {
my ($name, $sharer_id, $query_type) = @_; my ($name, $sharer_id, $query_type, $throw_error) = @_;
my $user = Bugzilla->login(LOGIN_REQUIRED); my $user = Bugzilla->login(LOGIN_REQUIRED);
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
my $owner_id; my $owner_id;
$throw_error = 1 unless defined $throw_error;
# $name and $sharer_id are safe -- we only use them below in SELECT # $name and $sharer_id are safe -- we only use them below in SELECT
# placeholders and then in error messages (which are always HTML-filtered). # placeholders and then in error messages (which are always HTML-filtered).
...@@ -243,9 +244,11 @@ sub LookupNamedQuery { ...@@ -243,9 +244,11 @@ sub LookupNamedQuery {
WHERE userid = ? AND name = ? WHERE userid = ? AND name = ?
$extra", $extra",
undef, @args); undef, @args);
defined($result) if (!defined($result)) {
|| ThrowUserError("missing_query", {'queryname' => $name, return 0 unless $throw_error;
'sharer_id' => $sharer_id}); ThrowUserError("missing_query", {'queryname' => $name,
'sharer_id' => $sharer_id});
}
if ($sharer_id) { if ($sharer_id) {
my $group = $dbh->selectrow_array('SELECT group_id my $group = $dbh->selectrow_array('SELECT group_id
...@@ -499,7 +502,13 @@ elsif (($cgi->param('cmdtype') eq "doit") && defined $cgi->param('remtype')) { ...@@ -499,7 +502,13 @@ elsif (($cgi->param('cmdtype') eq "doit") && defined $cgi->param('remtype')) {
} }
my %bug_ids; 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 # No new query name has been given. We retrieve bug IDs
# currently set in the selected saved search. # currently set in the selected saved search.
$query_name = $cgi->param('oldqueryname'); $query_name = $cgi->param('oldqueryname');
......
...@@ -1249,6 +1249,14 @@ ...@@ -1249,6 +1249,14 @@
No product specified when trying to edit components, milestones, versions No product specified when trying to edit components, milestones, versions
or product. 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" %] [% ELSIF error == "query_name_missing" %]
[% title = "No Search Name Specified" %] [% title = "No Search Name Specified" %]
[% docslinks = {'list.html' => "About $terms.bug lists"} %] [% docslinks = {'list.html' => "About $terms.bug lists"} %]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment