]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 277073: Make whining trap errors thrown by Search.pm
authorFrédéric Buclin <LpSolit@gmail.com>
Sun, 27 Nov 2011 23:00:20 +0000 (00:00 +0100)
committerFrédéric Buclin <LpSolit@gmail.com>
Sun, 27 Nov 2011 23:00:20 +0000 (00:00 +0100)
r=wicked a=LpSolit

template/en/default/global/messages.html.tmpl
whine.pl

index cad4758e26d5526406062c407cc2c5658138d07f..52502a1d75cdfbf392655e14e7147d0325955265 100644 (file)
       No changes made to version <em>[% version.name FILTER html %]</em>.
     [% END %]
 
+  [% ELSIF message_tag == "whine_query_failed" %]
+    The query '[% query_name FILTER html %]' from [% author.login FILTER html %]
+    failed: [% reason FILTER html %]
+
   [% ELSIF message_tag == "workflow_updated" %]
     The workflow has been updated.
   [% END %]
index 1f22b65fc4fffd9acd7c472e2b1abd14859e2bb4..12ad9a0e0c497d2e5dac3dd3e15a2e69e15eb5f4 100755 (executable)
--- a/whine.pl
+++ b/whine.pl
@@ -444,11 +444,17 @@ sub run_queries {
         # Bugzilla::Search to execute a saved query.  It's exceedingly weird,
         # but that's how it works.
         my $searchparams = new Bugzilla::CGI($savedquery);
-        my $search = new Bugzilla::Search(
+        my $search = eval { new Bugzilla::Search(
             'fields' => \@searchfields,
             'params' => $searchparams,
             'user'   => $args->{'recipient'}, # the search runs as the recipient
-        );
+        ) };
+        if ($@) {
+            print STDERR get_text('whine_query_failed', { query_name => $thisquery->{'name'},
+                                                          author => $args->{'author'},
+                                                          reason => $@ }) . "\n";
+            next;
+        }
         my $sqlquery = $search->getSQL();
         $sth = $dbh->prepare($sqlquery);
         $sth->execute;