Commit 8679e81c authored by Byron Jones's avatar Byron Jones

Bug 967607: User.get shouldn't load data that requires extra database queries unless required

r=dkl, a=justdave
parent eae63571
...@@ -17,7 +17,7 @@ use Bugzilla::Error; ...@@ -17,7 +17,7 @@ use Bugzilla::Error;
use Bugzilla::Group; use Bugzilla::Group;
use Bugzilla::User; use Bugzilla::User;
use Bugzilla::Util qw(trim); use Bugzilla::Util qw(trim);
use Bugzilla::WebService::Util qw(filter validate translate params_to_objects); use Bugzilla::WebService::Util qw(filter filter_wants validate translate params_to_objects);
use List::Util qw(first); use List::Util qw(first);
...@@ -226,9 +226,7 @@ sub get { ...@@ -226,9 +226,7 @@ sub get {
} }
} }
my $in_group = $self->_filter_users_by_group( my $in_group = $self->_filter_users_by_group(\@user_objects, $params);
\@user_objects, $params);
foreach my $user (@$in_group) { foreach my $user (@$in_group) {
my $user_info = { my $user_info = {
id => $self->type('int', $user->id), id => $self->type('int', $user->id),
...@@ -244,16 +242,28 @@ sub get { ...@@ -244,16 +242,28 @@ sub get {
} }
if (Bugzilla->user->id == $user->id) { if (Bugzilla->user->id == $user->id) {
$user_info->{saved_searches} = [map { $self->_query_to_hash($_) } @{ $user->queries }]; if (filter_wants($params, 'saved_searches')) {
$user_info->{saved_reports} = [map { $self->_report_to_hash($_) } @{ $user->reports }]; $user_info->{saved_searches} = [
map { $self->_query_to_hash($_) } @{ $user->queries }
];
}
if (filter_wants($params, 'saved_reports')) {
$user_info->{saved_reports} = [
map { $self->_report_to_hash($_) } @{ $user->reports }
];
}
} }
if (filter_wants($params, 'groups')) {
if (Bugzilla->user->id == $user->id || Bugzilla->user->in_group('editusers')) { if (Bugzilla->user->id == $user->id || Bugzilla->user->in_group('editusers')) {
$user_info->{groups} = [map {$self->_group_to_hash($_)} @{ $user->groups }]; $user_info->{groups} = [
map { $self->_group_to_hash($_) } @{ $user->groups }
];
} }
else { else {
$user_info->{groups} = $self->_filter_bless_groups($user->groups); $user_info->{groups} = $self->_filter_bless_groups($user->groups);
} }
}
push(@users, filter($params, $user_info)); push(@users, filter($params, $user_info));
} }
......
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