Commit 8b618be9 authored by Dave Lawrence's avatar Dave Lawrence

Bug 692507 - WebService API calls where appropriate should be using the…

Bug 692507 - WebService API calls where appropriate should be using the shadow_db for read only operations r=glob, a=LpSolit
parent 8eb3b175
...@@ -67,6 +67,8 @@ BEGIN { ...@@ -67,6 +67,8 @@ BEGIN {
sub fields { sub fields {
my ($self, $params) = validate(@_, 'ids', 'names'); my ($self, $params) = validate(@_, 'ids', 'names');
Bugzilla->switch_to_shadow_db();
my @fields; my @fields;
if (defined $params->{ids}) { if (defined $params->{ids}) {
my $ids = $params->{ids}; my $ids = $params->{ids};
...@@ -227,7 +229,7 @@ sub comments { ...@@ -227,7 +229,7 @@ sub comments {
my $bug_ids = $params->{ids} || []; my $bug_ids = $params->{ids} || [];
my $comment_ids = $params->{comment_ids} || []; my $comment_ids = $params->{comment_ids} || [];
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->switch_to_shadow_db();
my $user = Bugzilla->user; my $user = Bugzilla->user;
my %bugs; my %bugs;
...@@ -295,6 +297,8 @@ sub _translate_comment { ...@@ -295,6 +297,8 @@ sub _translate_comment {
sub get { sub get {
my ($self, $params) = validate(@_, 'ids'); my ($self, $params) = validate(@_, 'ids');
Bugzilla->switch_to_shadow_db();
my $ids = $params->{ids}; my $ids = $params->{ids};
defined $ids || ThrowCodeError('param_required', { param => 'ids' }); defined $ids || ThrowCodeError('param_required', { param => 'ids' });
...@@ -329,6 +333,8 @@ sub get { ...@@ -329,6 +333,8 @@ sub get {
sub history { sub history {
my ($self, $params) = validate(@_, 'ids'); my ($self, $params) = validate(@_, 'ids');
Bugzilla->switch_to_shadow_db();
my $ids = $params->{ids}; my $ids = $params->{ids};
defined $ids || ThrowCodeError('param_required', { param => 'ids' }); defined $ids || ThrowCodeError('param_required', { param => 'ids' });
...@@ -378,7 +384,9 @@ sub history { ...@@ -378,7 +384,9 @@ sub history {
sub search { sub search {
my ($self, $params) = @_; my ($self, $params) = @_;
Bugzilla->switch_to_shadow_db();
if ( defined($params->{offset}) and !defined($params->{limit}) ) { if ( defined($params->{offset}) and !defined($params->{limit}) ) {
ThrowCodeError('param_required', ThrowCodeError('param_required',
{ param => 'limit', function => 'Bug.search()' }); { param => 'limit', function => 'Bug.search()' });
...@@ -428,6 +436,8 @@ sub possible_duplicates { ...@@ -428,6 +436,8 @@ sub possible_duplicates {
my ($self, $params) = validate(@_, 'product'); my ($self, $params) = validate(@_, 'product');
my $user = Bugzilla->user; my $user = Bugzilla->user;
Bugzilla->switch_to_shadow_db();
# Undo the array-ification that validate() does, for "summary". # Undo the array-ification that validate() does, for "summary".
$params->{summary} || ThrowCodeError('param_required', $params->{summary} || ThrowCodeError('param_required',
{ function => 'Bug.possible_duplicates', param => 'summary' }); { function => 'Bug.possible_duplicates', param => 'summary' });
...@@ -540,6 +550,8 @@ sub create { ...@@ -540,6 +550,8 @@ sub create {
sub legal_values { sub legal_values {
my ($self, $params) = @_; my ($self, $params) = @_;
Bugzilla->switch_to_shadow_db();
defined $params->{field} defined $params->{field}
or ThrowCodeError('param_required', { param => 'field' }); or ThrowCodeError('param_required', { param => 'field' });
...@@ -721,6 +733,8 @@ sub update_see_also { ...@@ -721,6 +733,8 @@ sub update_see_also {
sub attachments { sub attachments {
my ($self, $params) = validate(@_, 'ids', 'attachment_ids'); my ($self, $params) = validate(@_, 'ids', 'attachment_ids');
Bugzilla->switch_to_shadow_db();
if (!(defined $params->{ids} if (!(defined $params->{ids}
or defined $params->{attachment_ids})) or defined $params->{attachment_ids}))
{ {
......
...@@ -47,23 +47,28 @@ BEGIN { *get_products = \&get } ...@@ -47,23 +47,28 @@ BEGIN { *get_products = \&get }
# Get the ids of the products the user can search # Get the ids of the products the user can search
sub get_selectable_products { sub get_selectable_products {
Bugzilla->switch_to_shadow_db();
return {ids => [map {$_->id} @{Bugzilla->user->get_selectable_products}]}; return {ids => [map {$_->id} @{Bugzilla->user->get_selectable_products}]};
} }
# Get the ids of the products the user can enter bugs against # Get the ids of the products the user can enter bugs against
sub get_enterable_products { sub get_enterable_products {
Bugzilla->switch_to_shadow_db();
return {ids => [map {$_->id} @{Bugzilla->user->get_enterable_products}]}; return {ids => [map {$_->id} @{Bugzilla->user->get_enterable_products}]};
} }
# Get the union of the products the user can search and enter bugs against. # Get the union of the products the user can search and enter bugs against.
sub get_accessible_products { sub get_accessible_products {
Bugzilla->switch_to_shadow_db();
return {ids => [map {$_->id} @{Bugzilla->user->get_accessible_products}]}; return {ids => [map {$_->id} @{Bugzilla->user->get_accessible_products}]};
} }
# Get a list of actual products, based on list of ids or names # Get a list of actual products, based on list of ids or names
sub get { sub get {
my ($self, $params) = validate(@_, 'ids', 'names'); my ($self, $params) = validate(@_, 'ids', 'names');
Bugzilla->switch_to_shadow_db();
# Only products that are in the users accessible products, # Only products that are in the users accessible products,
# can be allowed to be returned # can be allowed to be returned
my $accessible_products = Bugzilla->user->get_accessible_products; my $accessible_products = Bugzilla->user->get_accessible_products;
......
...@@ -114,6 +114,8 @@ sub create { ...@@ -114,6 +114,8 @@ sub create {
sub get { sub get {
my ($self, $params) = validate(@_, 'names', 'ids'); my ($self, $params) = validate(@_, 'names', 'ids');
Bugzilla->switch_to_shadow_db();
defined($params->{names}) || defined($params->{ids}) defined($params->{names}) || defined($params->{ids})
|| defined($params->{match}) || defined($params->{match})
|| ThrowCodeError('params_required', || ThrowCodeError('params_required',
......
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