]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 385003: Entering a tag name manually ("create and add the tag") should not silent...
authorlpsolit%gmail.com <>
Sat, 21 Jul 2007 16:48:27 +0000 (16:48 +0000)
committerlpsolit%gmail.com <>
Sat, 21 Jul 2007 16:48:27 +0000 (16:48 +0000)
buglist.cgi

index c9a4104857dc87e88724a422db9b59d18461bf34..96454d12cd03b120014e6d47601370ccd3a36651 100755 (executable)
@@ -511,17 +511,22 @@ elsif (($cgi->param('cmdtype') eq "doit") && defined $cgi->param('remtype')) {
             }
 
             my %bug_ids;
+            my $is_new_name = 0;
             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});
                 }
+                $is_new_name = 1;
             }
-            else {
-                # No new query name has been given. We retrieve bug IDs
-                # currently set in the selected saved search.
-                $query_name = $cgi->param('oldqueryname');
-                my $old_query = LookupNamedQuery($query_name, undef, LIST_OF_BUGS);
+            # If no new tag name has been given, use the selected one.
+            $query_name ||= $cgi->param('oldqueryname');
+
+            # Don't throw an error if it's a new tag name: if the tag already
+            # exists, add/remove bugs to it, else create it. But if we are
+            # considering an existing tag, then it has to exist and we throw
+            # an error if it doesn't (hence the usage of !$is_new_name).
+            if (my $old_query = LookupNamedQuery($query_name, undef, LIST_OF_BUGS, !$is_new_name)) {
                 # We get the encoded query. We need to decode it.
                 my $old_cgi = new Bugzilla::CGI($old_query);
                 foreach my $bug_id (split /[\s,]+/, scalar $old_cgi->param('bug_id')) {