Commit ed9e593a authored by Max Kanat-Alexander's avatar Max Kanat-Alexander

Bug 577800: Finish the cleanup of Search.pm's "init" function by removing

it and having its work be done by a new "sql" accessor instead. Also adds some comments, moves functions around into sections, and creates a new _user accessor. r=mkanat, a=mkanat (module owner)
parent a8577a8e
...@@ -851,7 +851,7 @@ my @orderstrings = split(/,\s*/, $order); ...@@ -851,7 +851,7 @@ my @orderstrings = split(/,\s*/, $order);
my $search = new Bugzilla::Search('fields' => \@selectcolumns, my $search = new Bugzilla::Search('fields' => \@selectcolumns,
'params' => $params, 'params' => $params,
'order' => \@orderstrings); 'order' => \@orderstrings);
my $query = $search->getSQL(); my $query = $search->sql;
$vars->{'search_description'} = $search->search_description; $vars->{'search_description'} = $search->search_description;
if (defined $cgi->param('limit')) { if (defined $cgi->param('limit')) {
......
...@@ -512,7 +512,7 @@ sub CollectSeriesData { ...@@ -512,7 +512,7 @@ sub CollectSeriesData {
my $search = new Bugzilla::Search('params' => $cgi, my $search = new Bugzilla::Search('params' => $cgi,
'fields' => ["bug_id"], 'fields' => ["bug_id"],
'user' => $user); 'user' => $user);
my $sql = $search->getSQL(); my $sql = $search->sql;
$data = $shadow_dbh->selectall_arrayref($sql); $data = $shadow_dbh->selectall_arrayref($sql);
}; };
......
...@@ -128,7 +128,7 @@ my @axis_fields = ($row_field || EMPTY_COLUMN, ...@@ -128,7 +128,7 @@ my @axis_fields = ($row_field || EMPTY_COLUMN,
my $params = new Bugzilla::CGI($cgi); my $params = new Bugzilla::CGI($cgi);
my $search = new Bugzilla::Search('fields' => \@axis_fields, my $search = new Bugzilla::Search('fields' => \@axis_fields,
'params' => $params); 'params' => $params);
my $query = $search->getSQL(); my $query = $search->sql;
$::SIG{TERM} = 'DEFAULT'; $::SIG{TERM} = 'DEFAULT';
$::SIG{PIPE} = 'DEFAULT'; $::SIG{PIPE} = 'DEFAULT';
......
...@@ -449,7 +449,7 @@ sub run_queries { ...@@ -449,7 +449,7 @@ sub run_queries {
'params' => $searchparams, 'params' => $searchparams,
'user' => $args->{'recipient'}, # the search runs as the recipient 'user' => $args->{'recipient'}, # the search runs as the recipient
); );
my $sqlquery = $search->getSQL(); my $sqlquery = $search->sql;
$sth = $dbh->prepare($sqlquery); $sth = $dbh->prepare($sqlquery);
$sth->execute; $sth->execute;
......
...@@ -497,20 +497,17 @@ sub do_tests { ...@@ -497,20 +497,17 @@ sub do_tests {
my $search_broken = $self->search_known_broken; my $search_broken = $self->search_known_broken;
my $search; my $search = $self->_test_search_object_creation();
my $sql;
TODO: { TODO: {
local $TODO = $search_broken if $search_broken; local $TODO = $search_broken if $search_broken;
$search = $self->_test_search_object_creation(); lives_ok { $sql = $search->sql } "$name: generate SQL";
} }
my ($results, $sql); my $results;
SKIP: { SKIP: {
skip "Can't run SQL without Search object", 2 if !$search; skip "Can't run SQL without any SQL", 1 if !defined $sql;
lives_ok { $sql = $search->getSQL() } "$name: get SQL";
# This prevents warnings from DBD::mysql if we pass undef $sql,
# which happens if "new Bugzilla::Search" fails.
$sql ||= '';
$results = $self->_test_sql($sql); $results = $self->_test_sql($sql);
} }
......
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