Commit 5818051f authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 257351: collectstats.pl dies if an invalid series is defined - Patch by…

Bug 257351: collectstats.pl dies if an invalid series is defined - Patch by Fré©ric Buclin <LpSolit@gmail.com> r/a=mkanat
parent ae89fa81
...@@ -324,7 +324,7 @@ sub sql_group_by { ...@@ -324,7 +324,7 @@ sub sql_group_by {
my ($self, $needed_columns, $optional_columns) = @_; my ($self, $needed_columns, $optional_columns) = @_;
my $expression = "GROUP BY $needed_columns"; my $expression = "GROUP BY $needed_columns";
$expression .= ", " . $optional_columns if defined($optional_columns); $expression .= ", " . $optional_columns if $optional_columns;
return $expression; return $expression;
} }
......
...@@ -579,22 +579,19 @@ sub CollectSeriesData { ...@@ -579,22 +579,19 @@ sub CollectSeriesData {
# We set up the user for Search.pm's permission checking - each series # We set up the user for Search.pm's permission checking - each series
# runs with the permissions of its creator. # runs with the permissions of its creator.
my $user = new Bugzilla::User($serieses->{$series_id}->{'creator'}); my $user = new Bugzilla::User($serieses->{$series_id}->{'creator'});
my $cgi = new Bugzilla::CGI($serieses->{$series_id}->{'query'}); 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; my $data;
# We can't die if we get dodgy SQL back for whatever reason, so we # Do not die if Search->new() detects invalid data, such as an obsolete
# eval() this and, if it fails, just ignore it and carry on. # login name or a renamed product or component, etc.
# One day we might even log an error. eval {
eval { my $search = new Bugzilla::Search('params' => $cgi,
'fields' => ["bugs.bug_id"],
'user' => $user);
my $sql = $search->getSQL();
$data = $shadow_dbh->selectall_arrayref($sql); $data = $shadow_dbh->selectall_arrayref($sql);
}; };
if (!$@) { if (!$@) {
# We need to count the returned rows. Without subselects, we can't # 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. # do this directly in the SQL for all queries. So we do it by hand.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment