From 19ed962da0462de624c15ad890da796b32fd3a50 Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" Date: Sun, 25 Sep 2005 21:04:30 +0000 Subject: [PATCH] Bug 308228: Whine-related saved search can be forgotten through buglist.cgi - Patch by A. Karl Kornel r=LpSolit a=justdave --- webtools/bugzilla/buglist.cgi | 21 +++++++++++++++++++ .../en/default/global/user-error.html.tmpl | 9 +++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/webtools/bugzilla/buglist.cgi b/webtools/bugzilla/buglist.cgi index 1e4ab0cb5c8..f8f81d3e515 100755 --- a/webtools/bugzilla/buglist.cgi +++ b/webtools/bugzilla/buglist.cgi @@ -388,6 +388,27 @@ if ($cgi->param('cmdtype') eq "dorem") { # the SQL, and the SQL is only a DELETE. my $qname = $cgi->param('namedcmd'); trick_taint($qname); + + # Do not forget the saved search if it is being used in a whine + my $whines_in_use = + $dbh->selectcol_arrayref('SELECT DISTINCT whine_events.subject + FROM whine_events + INNER JOIN whine_queries + ON whine_queries.eventid + = whine_events.id + WHERE whine_events.owner_userid + = ? + AND whine_queries.query_name + = ? + ', undef, Bugzilla->user->id, $qname); + if (scalar(@$whines_in_use)) { + ThrowUserError('saved_search_used_by_whines', + { subjects => join(',', @$whines_in_use), + search_name => $qname } + ); + } + + # If we are here, then we can safely remove the saved search $dbh->do("DELETE FROM namedqueries" . " WHERE userid = ? AND name = ?" , undef, ($userid, $qname)); diff --git a/webtools/bugzilla/template/en/default/global/user-error.html.tmpl b/webtools/bugzilla/template/en/default/global/user-error.html.tmpl index b77e58d1619..8288a309daa 100644 --- a/webtools/bugzilla/template/en/default/global/user-error.html.tmpl +++ b/webtools/bugzilla/template/en/default/global/user-error.html.tmpl @@ -1055,6 +1055,12 @@ [% title = "Summary Needed" %] You must enter a summary for this [% terms.bug %]. + [% ELSIF error == "saved_search_used_by_whines" %] + [% title = "Saved Search In Use" %] + The saved search [% search_name FILTER html %] is being used + by Whining events with the following subjects: + [%+ subjects FILTER html %] + [% ELSIF error == "search_content_without_matches" %] [% title = "Illegal Search" %] The "content" field can only be used with "matches" search @@ -1238,7 +1244,8 @@ [% USE Bugzilla %] [% namedcmd = Bugzilla.cgi.param("namedcmd") %] -[% IF namedcmd AND error != "missing_query" %] +[% IF namedcmd AND error != "missing_query" + AND error != "saved_search_used_by_whines" %]

Alternatively, you can