]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1232186: Component.update and Component.delete are broken
authorFrédéric Buclin <LpSolit@gmail.com>
Fri, 18 Dec 2015 11:50:05 +0000 (12:50 +0100)
committerFrédéric Buclin <LpSolit@gmail.com>
Fri, 18 Dec 2015 11:50:05 +0000 (12:50 +0100)
r=dkl

Bugzilla/API/1_0/Resource/Component.pm
Bugzilla/WebService/Component.pm

index 96c2a3dcdc09ba5f65943b43c25f071d7e7d986e..13a5f24b51e70b928de81747d9434b43f07ab1f8 100644 (file)
@@ -28,6 +28,8 @@ extends 'Bugzilla::API::1_0::Resource';
 
 use constant PUBLIC_METHODS => qw(
     create
+    delete
+    update
 );
 
 use constant CREATE_MAPPED_FIELDS => {
@@ -129,7 +131,7 @@ sub _component_params_to_objects {
         # To get the component objects for product/component combination
         # first obtain the product object from the passed product name
         foreach my $name_hash (@{$params->{names}}) {
-            my $product = $user->can_admin_product($name_hash->{product});
+            my $product = $user->check_can_admin_product($name_hash->{product});
             push @components, @{ Bugzilla::Component->match({
                 product_id => $product->id,
                 name       => $name_hash->{component}
@@ -157,9 +159,8 @@ sub _component_params_to_objects {
 sub update {
     my ($self, $params) = @_;
     my $dbh  = Bugzilla->dbh;
-    my $user = Bugzilla->user;
+    my $user = Bugzilla->login(LOGIN_REQUIRED);
 
-    Bugzilla->login(LOGIN_REQUIRED);
     $user->in_group('editcomponents')
         || scalar @{ $user->get_products_by_permission('editcomponents') }
         || ThrowUserError("auth_failure", { group  => "editcomponents",
@@ -248,11 +249,9 @@ sub update {
 
 sub delete {
     my ($self, $params) = @_;
-
     my $dbh  = Bugzilla->dbh;
-    my $user = Bugzilla->user;
+    my $user = Bugzilla->login(LOGIN_REQUIRED);
 
-    Bugzilla->login(LOGIN_REQUIRED);
     $user->in_group('editcomponents')
         || scalar @{ $user->get_products_by_permission('editcomponents') }
         || ThrowUserError("auth_failure", { group  => "editcomponents",
index 9f3dfb4d4cde6f85a177c9843271efe6255314f1..a590874926f8f0d01cf10a0b0b120b5246a2a789 100644 (file)
@@ -21,6 +21,8 @@ use Bugzilla::WebService::Util qw(translate params_to_objects validate);
 
 use constant PUBLIC_METHODS => qw(
     create
+    delete
+    update
 );
 
 use constant CREATE_MAPPED_FIELDS => {
@@ -78,7 +80,7 @@ sub _component_params_to_objects {
         # To get the component objects for product/component combination
         # first obtain the product object from the passed product name
         foreach my $name_hash (@{$params->{names}}) {
-            my $product = $user->can_admin_product($name_hash->{product});
+            my $product = $user->check_can_admin_product($name_hash->{product});
             push @components, @{ Bugzilla::Component->match({
                 product_id => $product->id,
                 name       => $name_hash->{component}
@@ -106,9 +108,8 @@ sub _component_params_to_objects {
 sub update {
     my ($self, $params) = @_;
     my $dbh  = Bugzilla->dbh;
-    my $user = Bugzilla->user;
+    my $user = Bugzilla->login(LOGIN_REQUIRED);
 
-    Bugzilla->login(LOGIN_REQUIRED);
     $user->in_group('editcomponents')
         || scalar @{ $user->get_products_by_permission('editcomponents') }
         || ThrowUserError("auth_failure", { group  => "editcomponents",
@@ -197,11 +198,9 @@ sub update {
 
 sub delete {
     my ($self, $params) = @_;
-
     my $dbh  = Bugzilla->dbh;
-    my $user = Bugzilla->user;
+    my $user = Bugzilla->login(LOGIN_REQUIRED);
 
-    Bugzilla->login(LOGIN_REQUIRED);
     $user->in_group('editcomponents')
         || scalar @{ $user->get_products_by_permission('editcomponents') }
         || ThrowUserError("auth_failure", { group  => "editcomponents",