From 64255ff8cb00fc7308130f6a6db2a431b92cccc1 Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" Date: Mon, 20 Aug 2007 18:11:47 +0000 Subject: [PATCH] =?UTF-8?q?Bug=20257351:=20collectstats.pl=20dies=20if=20a?= =?UTF-8?q?n=20invalid=20series=20is=20defined=20-=20Patch=20by=20Fr=C3=83?= =?UTF-8?q?=C2=A9d=C3=83=C2=A9ric=20Buclin=20=20r/a=3Dm?= =?UTF-8?q?kanat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://10.0.0.236/trunk@232393 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/webtools/bugzilla/Bugzilla/DB.pm | 2 +- mozilla/webtools/bugzilla/collectstats.pl | 21 +++++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/mozilla/webtools/bugzilla/Bugzilla/DB.pm b/mozilla/webtools/bugzilla/Bugzilla/DB.pm index b43b237eb41..7384e7b5ff7 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/DB.pm +++ b/mozilla/webtools/bugzilla/Bugzilla/DB.pm @@ -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; } diff --git a/mozilla/webtools/bugzilla/collectstats.pl b/mozilla/webtools/bugzilla/collectstats.pl index 730b8c50f1e..a1ab9b2d197 100755 --- a/mozilla/webtools/bugzilla/collectstats.pl +++ b/mozilla/webtools/bugzilla/collectstats.pl @@ -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.