Remove old LookupNamedQuery API, rename Bugzilla::Search::Saved->url to ->query
parent
c58b218875
commit
33b91f8d94
|
@ -3019,7 +3019,7 @@ sub _changedby
|
|||
sub _in_search_results
|
||||
{
|
||||
my $self = shift;
|
||||
my $query = LookupNamedQuery(trim($self->{value}));
|
||||
my $query = Bugzilla::Search::Saved->check({ name => trim($self->{value}) })->query;
|
||||
my $search = new Bugzilla::Search(
|
||||
params => http_decode_query($query),
|
||||
fields => [ "bugs.bug_id" ],
|
||||
|
@ -3039,38 +3039,6 @@ sub _in_search_results
|
|||
}
|
||||
}
|
||||
|
||||
sub LookupNamedQuery
|
||||
{
|
||||
my ($name, $sharer_id, $throw_error) = @_;
|
||||
$throw_error = THROW_ERROR unless defined $throw_error;
|
||||
|
||||
Bugzilla->login(LOGIN_REQUIRED);
|
||||
|
||||
my $constructor = $throw_error ? 'check' : 'new';
|
||||
my $query = Bugzilla::Search::Saved->$constructor(
|
||||
{ user => $sharer_id, name => $name });
|
||||
|
||||
if (!$query)
|
||||
{
|
||||
if ($throw_error)
|
||||
{
|
||||
ThrowUserError("missing_query", { queryname => $name,
|
||||
sharer_id => $sharer_id });
|
||||
}
|
||||
else
|
||||
{
|
||||
return undef;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$query->url)
|
||||
{
|
||||
ThrowUserError("buglist_parameters_required", { queryname => $name });
|
||||
}
|
||||
|
||||
return wantarray ? ($query->url, $query->id) : $query->url;
|
||||
}
|
||||
|
||||
##########################################################
|
||||
## SQL Core of Bugzilla::Search: functions for building ##
|
||||
## queries from structured expressions ##
|
||||
|
|
|
@ -237,16 +237,16 @@ sub remove_from_db
|
|||
# Complex Accessors #
|
||||
#####################
|
||||
|
||||
sub edit_link {
|
||||
sub edit_link
|
||||
{
|
||||
my ($self) = @_;
|
||||
return $self->{edit_link} if defined $self->{edit_link};
|
||||
my $cgi = new Bugzilla::CGI($self->url);
|
||||
if (!$cgi->param('query_type')
|
||||
|| !IsValidQueryType($cgi->param('query_type')))
|
||||
my $params = http_decode_query($self->query);
|
||||
if (!$params->{query_type} || !IsValidQueryType($params->{query_type}))
|
||||
{
|
||||
$cgi->param('query_type', 'advanced');
|
||||
$params->{query_type} = 'advanced';
|
||||
}
|
||||
$self->{edit_link} = $cgi->canonicalise_query;
|
||||
$self->{edit_link} = http_build_query($params);
|
||||
return $self->{edit_link};
|
||||
}
|
||||
|
||||
|
@ -321,7 +321,7 @@ sub shared_with_users {
|
|||
# Simple Accessors #
|
||||
####################
|
||||
|
||||
sub url { $_[0]->{query}; }
|
||||
sub query { $_[0]->{query}; }
|
||||
sub userid { $_[0]->{userid} }
|
||||
|
||||
sub user {
|
||||
|
@ -337,7 +337,7 @@ sub user {
|
|||
############
|
||||
|
||||
sub set_name { $_[0]->set('name', $_[1]); }
|
||||
sub set_url { $_[0]->set('query', $_[1]); }
|
||||
sub set_query { $_[0]->set('query', $_[1]); }
|
||||
|
||||
sub set_link_in_footer
|
||||
{
|
||||
|
@ -419,7 +419,7 @@ Bugzilla::Search::Saved - A saved search
|
|||
my $query = new Bugzilla::Search::Saved($query_id);
|
||||
|
||||
my $edit_link = $query->edit_link;
|
||||
my $search_url = $query->url;
|
||||
my $search_url = $query->query;
|
||||
my $owner = $query->user;
|
||||
my $num_subscribers = $query->shared_with_users;
|
||||
|
||||
|
|
33
buglist.cgi
33
buglist.cgi
|
@ -304,7 +304,7 @@ sub InsertNamedQuery
|
|||
if ($query_obj)
|
||||
{
|
||||
$query_obj->set_name($query_name);
|
||||
$query_obj->set_url($query);
|
||||
$query_obj->set_query($query);
|
||||
$query_obj->update();
|
||||
}
|
||||
else
|
||||
|
@ -446,26 +446,25 @@ if ($cmdtype eq "dorem")
|
|||
{
|
||||
if ($remaction eq "run")
|
||||
{
|
||||
my $query_id;
|
||||
($buffer, $query_id) = Bugzilla::Search::LookupNamedQuery(
|
||||
scalar $cgi->param("namedcmd"), scalar $cgi->param('sharer_id')
|
||||
);
|
||||
# If this is the user's own query, remember information about it
|
||||
# so that it can be modified easily.
|
||||
$vars->{searchname} = $cgi->param('namedcmd');
|
||||
if (!$cgi->param('sharer_id') ||
|
||||
$cgi->param('sharer_id') == Bugzilla->user->id)
|
||||
{
|
||||
$vars->{searchtype} = "saved";
|
||||
$vars->{search_id} = $query_id;
|
||||
}
|
||||
if ($buffer =~ m!^[a-z][a-z0-9]*://!so)
|
||||
my $query = Bugzilla::Search::Saved->check({
|
||||
name => scalar $cgi->param('namedcmd'),
|
||||
user => scalar $cgi->param('sharer_id'),
|
||||
});
|
||||
if ($query->query =~ m!^[a-z][a-z0-9]*://!so)
|
||||
{
|
||||
# CustIS Bug 53697: Custom links in saved searches and footer/header
|
||||
print $cgi->redirect(-location => $buffer);
|
||||
print $cgi->redirect(-location => $query->query);
|
||||
exit;
|
||||
}
|
||||
$params = http_decode_query($buffer);
|
||||
# If this is the user's own query, remember information about it
|
||||
# so that it can be modified easily.
|
||||
$vars->{searchname} = $query->name;
|
||||
if ($query->userid == Bugzilla->user->id)
|
||||
{
|
||||
$vars->{searchtype} = 'saved';
|
||||
$vars->{search_id} = $query->id;
|
||||
}
|
||||
$params = http_decode_query($query->query);
|
||||
$order = $params->{order} || $order;
|
||||
}
|
||||
elsif ($remaction eq "runseries")
|
||||
|
|
|
@ -98,17 +98,17 @@ if (defined $cgi->param('rememberedquery')) {
|
|||
}
|
||||
|
||||
if ($cgi->param('save_columns_for_search')
|
||||
&& defined $search && $search->user->id == Bugzilla->user->id)
|
||||
&& defined $search && $search->user->id == Bugzilla->user->id)
|
||||
{
|
||||
my $params = new Bugzilla::CGI($search->url);
|
||||
$params->param('columnlist', join(",", @collist));
|
||||
$search->set_url($params->query_string());
|
||||
my $params = http_decode_query($search->query);
|
||||
$params->{columnlist} = join(",", @collist);
|
||||
$search->set_query(http_build_query($params));
|
||||
$search->update();
|
||||
}
|
||||
|
||||
my $params = new Bugzilla::CGI($cgi->param('rememberedquery'));
|
||||
$params->param('columnlist', join(",", @collist));
|
||||
$vars->{'redirect_url'} = "buglist.cgi?".$params->query_string();
|
||||
my $params = http_decode_query($cgi->param('rememberedquery'));
|
||||
$params->{columnlist} = join(",", @collist);
|
||||
$vars->{redirect_url} = "buglist.cgi?".http_build_query($params);
|
||||
|
||||
# If we're running on Microsoft IIS, $cgi->redirect discards
|
||||
# the Set-Cookie lines. In mod_perl, $cgi->redirect with cookies
|
||||
|
|
|
@ -84,7 +84,7 @@ sub refresh_sql
|
|||
$query = $self->query;
|
||||
}
|
||||
my $search = new Bugzilla::Search(
|
||||
params => http_decode_query($query->url),
|
||||
params => http_decode_query($query->query),
|
||||
fields => [ 'bug_id' ],
|
||||
user => $query->user,
|
||||
);
|
||||
|
@ -142,7 +142,7 @@ sub _check_query_id
|
|||
ThrowUserError('query_access_denied', { query => $q });
|
||||
}
|
||||
# Тоже наша доработка - в сохранённый поиск может быть сохранён просто левый URL
|
||||
if ($q->url =~ /^[a-z][a-z0-9]*:/iso)
|
||||
if ($q->query =~ /^[a-z][a-z0-9]*:/iso)
|
||||
{
|
||||
ThrowUserError('query_not_savedsearch', { query => $q });
|
||||
}
|
||||
|
|
|
@ -79,8 +79,8 @@ sub refresh_some_views
|
|||
$q =~ tr/_/%/;
|
||||
($q) = $dbh->selectrow_array('SELECT name FROM namedqueries WHERE userid=? AND name LIKE ? LIMIT 1', undef, $userid, $q);
|
||||
$q or next;
|
||||
my $storedquery = Bugzilla::Search::LookupNamedQuery($q, $userid, 0) or next;
|
||||
$storedquery = http_decode_query($storedquery);
|
||||
my $storedquery = Bugzilla::Search::Saved->new({ name => $q, user => $userid }) or next;
|
||||
$storedquery = http_decode_query($storedquery->query);
|
||||
# get SQL code
|
||||
my $search = new Bugzilla::Search(
|
||||
params => $storedquery,
|
||||
|
|
|
@ -114,13 +114,13 @@ if (@idlist || @lines)
|
|||
exit;
|
||||
}
|
||||
|
||||
my ($query, $query_id) = Bugzilla::Search::LookupNamedQuery('MyWorktimeBugs', undef, 0);
|
||||
my $query = Bugzilla::Search::Saved->new({ name => 'MyWorktimeBugs' });
|
||||
|
||||
my $sqlquery = "";
|
||||
if ($query_id)
|
||||
if ($query)
|
||||
{
|
||||
my $search = new Bugzilla::Search(
|
||||
params => http_decode_query($query),
|
||||
params => http_decode_query($query->query),
|
||||
fields => [ "bugs.bug_id" ],
|
||||
);
|
||||
$sqlquery = $search->bugid_query;
|
||||
|
|
|
@ -43,7 +43,7 @@ $limit = 100 if !$limit || $limit < 1;
|
|||
my $title = $ARGS->{namedcmd};
|
||||
if ($title)
|
||||
{
|
||||
my $storedquery = Bugzilla::Search::LookupNamedQuery($title, $user->id);
|
||||
my $storedquery = Bugzilla::Search::Saved->check({ name => $title })->query;
|
||||
$ARGS = http_decode_query($storedquery);
|
||||
}
|
||||
|
||||
|
|
18
whine.pl
18
whine.pl
|
@ -55,9 +55,6 @@ my $sth_run_queries =
|
|||
"FROM whine_queries " .
|
||||
"WHERE eventid=? " .
|
||||
"ORDER BY sortkey");
|
||||
my $sth_get_query =
|
||||
$dbh->prepare("SELECT query FROM namedqueries " .
|
||||
"WHERE userid = ? AND name = ?");
|
||||
|
||||
# get the event that's scheduled with the lowest run_next value
|
||||
my $sth_next_scheduled_event = $dbh->prepare(
|
||||
|
@ -427,7 +424,7 @@ sub run_queries {
|
|||
foreach my $thisquery (@queries) {
|
||||
next unless $thisquery->{'name'}; # named query is blank
|
||||
|
||||
my $savedquery = get_query($thisquery->{'name'}, $args->{'author'});
|
||||
my $savedquery = Bugzilla::Search::Saved->new({ name => $thisquery->{name}, user => $args->{author} });
|
||||
next unless $savedquery; # silently ignore missing queries
|
||||
|
||||
# Execute the saved query
|
||||
|
@ -481,19 +478,6 @@ sub run_queries {
|
|||
return $return_queries;
|
||||
}
|
||||
|
||||
# get_query gets the namedquery. It's similar to LookupNamedQuery (in
|
||||
# buglist.cgi), but doesn't care if a query name really exists or not, since
|
||||
# individual named queries might go away without the whine_queries that point
|
||||
# to them being removed.
|
||||
sub get_query {
|
||||
my ($name, $user) = @_;
|
||||
my $qname = $name;
|
||||
$sth_get_query->execute($user->id, $qname);
|
||||
my $fetched = $sth_get_query->fetch;
|
||||
$sth_get_query->finish;
|
||||
return $fetched ? $fetched->[0] : '';
|
||||
}
|
||||
|
||||
# check_today gets a run day from the schedule and sees if it matches today
|
||||
# a run day value can contain any of:
|
||||
# - a three-letter day of the week
|
||||
|
|
Loading…
Reference in New Issue