]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 257351: collectstats.pl dies if an invalid series is defined - Patch by FrédÃ...
authorlpsolit%gmail.com <>
Mon, 20 Aug 2007 23:04:19 +0000 (23:04 +0000)
committerlpsolit%gmail.com <>
Mon, 20 Aug 2007 23:04:19 +0000 (23:04 +0000)
Bugzilla/DB.pm
collectstats.pl

index b43b237eb4135324c55e05d0d2b65387fdfd153e..7384e7b5ff797d1ae8a02b61f844f5b4e503b5e5 100644 (file)
@@ -324,7 +324,7 @@ sub sql_group_by {
     my ($self, $needed_columns, $optional_columns) = @_;
 
     my $expression = "GROUP BY $needed_columns";
-    $expression .= ", " . $optional_columns if defined($optional_columns);
+    $expression .= ", " . $optional_columns if $optional_columns;
     
     return $expression;
 }
index 730b8c50f1e47392be4d0550352e0d3f43152fec..a1ab9b2d1976ede3202722870a95155465bb4070 100755 (executable)
@@ -579,22 +579,19 @@ sub CollectSeriesData {
         # We set up the user for Search.pm's permission checking - each series
         # runs with the permissions of its creator.
         my $user = new Bugzilla::User($serieses->{$series_id}->{'creator'});
-
         my $cgi = new Bugzilla::CGI($serieses->{$series_id}->{'query'});
-        my $search = new Bugzilla::Search('params' => $cgi,
-                                          'fields' => ["bugs.bug_id"],
-                                          'user'   => $user);
-        my $sql = $search->getSQL();
-        
         my $data;
-        
-        # We can't die if we get dodgy SQL back for whatever reason, so we
-        # eval() this and, if it fails, just ignore it and carry on.
-        # One day we might even log an error.
-        eval { 
+
+        # Do not die if Search->new() detects invalid data, such as an obsolete
+        # login name or a renamed product or component, etc.
+        eval {
+            my $search = new Bugzilla::Search('params' => $cgi,
+                                              'fields' => ["bugs.bug_id"],
+                                              'user'   => $user);
+            my $sql = $search->getSQL();
             $data = $shadow_dbh->selectall_arrayref($sql);
         };
-        
+
         if (!$@) {
             # We need to count the returned rows. Without subselects, we can't
             # do this directly in the SQL for all queries. So we do it by hand.