]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1518886 - Remove outdated build plan code from PhabBugz extension used to move...
authordklawren <dklawren@users.noreply.github.com>
Thu, 17 Jan 2019 18:57:09 +0000 (13:57 -0500)
committerGitHub <noreply@github.com>
Thu, 17 Jan 2019 18:57:09 +0000 (13:57 -0500)
extensions/PhabBugz/lib/Feed.pm
extensions/PhabBugz/lib/WebService.pm

index a1d5e0f77960662e63c6ae11bdef2f073f1b58ff..8c204204e6df33755318c1bdc02d6782c86a121b 100644 (file)
@@ -192,46 +192,10 @@ sub feed_query {
     # Load the revision from Phabricator
     my $revision = Bugzilla::Extension::PhabBugz::Revision->new_from_query(
       {phids => [$object_phid]});
-    $self->process_revision_change($revision, $author, $story_text, 0);
+    $self->process_revision_change($revision, $author, $story_text);
     $self->save_last_id($story_id, 'feed');
   }
 
-  # Process any build targets as well.
-  my $dbh = Bugzilla->dbh;
-
-  INFO("Checking for revisions with pending build plan");
-  my $build_targets
-    = $dbh->selectall_arrayref(
-    "SELECT name, value FROM phabbugz WHERE name LIKE 'build_target_%'",
-    {Slice => {}});
-
-  my $delete_build_target
-    = $dbh->prepare("DELETE FROM phabbugz WHERE name = ? AND VALUE = ?");
-
-  foreach my $target (@$build_targets) {
-    my ($revision_id) = ($target->{name} =~ /^build_target_(\d+)$/);
-    my $build_target = $target->{value};
-
-    next unless $revision_id && $build_target;
-
-    INFO("Processing revision $revision_id with build target $build_target");
-
-    my $revision
-      = Bugzilla::Extension::PhabBugz::Revision->new_from_query({
-      ids => [int($revision_id)]
-      });
-
-    $self->process_revision_change($revision, $revision->author,
-      " created D" . $revision->id, 1);
-
-    # Set the build target to a passing status to
-    # allow the revision to exit draft state
-    request('harbormaster.sendmessage',
-      {buildTargetPHID => $build_target, type => 'pass'});
-
-    $delete_build_target->execute($target->{name}, $target->{value});
-  }
-
   if (Bugzilla->datadog) {
     my $dd = Bugzilla->datadog();
     $dd->increment('bugzilla.phabbugz.feed_query_count');
@@ -381,8 +345,8 @@ sub group_query {
 }
 
 sub process_revision_change {
-  state $check = compile($Invocant, Revision, LinkedPhabUser, Str, Bool);
-  my ($self, $revision, $changer, $story_text, $from_build_plan) = $check->(@_);
+  state $check = compile($Invocant, Revision, LinkedPhabUser, Str);
+  my ($self, $revision, $changer, $story_text) = $check->(@_);
   my $is_new = $story_text =~ /\s+created\s+D\d+/;
 
   # NO BUG ID
@@ -392,7 +356,7 @@ sub process_revision_change {
       # If new revision and bug id was omitted, make revision public
       INFO("No bug associated with new revision. Marking public.");
       $revision->make_public();
-      if ($revision->status eq 'draft' && !$from_build_plan) {
+      if ($revision->status eq 'draft') {
         INFO("Moving from draft to needs-review");
         $revision->set_status('request-review');
       }
@@ -530,7 +494,7 @@ sub process_revision_change {
   }
 
   # Set status to request-review if revision is new and in draft state
-  if ($is_new && $revision->status eq 'draft' && !$from_build_plan) {
+  if ($is_new && $revision->status eq 'draft') {
     INFO("Moving from draft to needs-review");
     $revision->set_status('request-review');
   }
index f5e3357d9086b68d70550a1b98dba06d2e0cb47f..bca05d303459a10d19bed90b0767a5872cb3fc8f 100644 (file)
@@ -40,7 +40,6 @@ use constant PUBLIC_METHODS => qw(
   bug_revisions
   check_user_enter_bug_permission
   check_user_permission_for_bug
-  set_build_target
 );
 
 sub _check_phabricator {
@@ -97,43 +96,6 @@ sub check_user_enter_bug_permission {
   return {result => $target_user->can_enter_product($params->{product}) ? 1 : 0};
 }
 
-sub set_build_target {
-  my ($self, $params) = @_;
-
-  # Phabricator only supports sending credentials via HTTP Basic Auth
-  # so we exploit that function to pass in an API key as the password
-  # of basic auth. BMO does not support basic auth but does support
-  # use of API keys.
-  my $http_auth = Bugzilla->cgi->http('Authorization');
-  $http_auth =~ s/^Basic\s+//;
-  $http_auth = decode_base64($http_auth);
-  my ($login, $api_key) = split(':', $http_auth);
-  $params->{'Bugzilla_login'}   = $login;
-  $params->{'Bugzilla_api_key'} = $api_key;
-
-  my $user = Bugzilla->login(LOGIN_REQUIRED);
-
-  $self->_validate_phab_user($user);
-
-  my $revision_id  = $params->{revision_id};
-  my $build_target = $params->{build_target};
-
-  ThrowUserError('invalid_phabricator_revision_id')
-    unless detaint_natural($revision_id);
-
-  ThrowUserError('invalid_phabricator_build_target')
-    unless $build_target =~ /^PHID-HMBT-[a-zA-Z0-9]+$/;
-  trick_taint($build_target);
-
-  Bugzilla->dbh->do(
-    'INSERT INTO phabbugz (name, value) VALUES (?, ?)',
-    undef, 'build_target_' . $revision_id,
-    $build_target
-  );
-
-  return {result => 1};
-}
-
 sub bug_revisions {
   state $check = compile(Object, Dict [bug_id => Int]);
   my ($self, $params) = $check->(@_);
@@ -241,17 +203,6 @@ sub bug_revisions {
 
 sub rest_resources {
   return [
-    # Set build target in Phabricator
-    qr{^/phabbugz/build_target/(\d+)/(PHID-HMBT-.*)$},
-    {
-      POST => {
-        method => 'set_build_target',
-        params => sub {
-          return {revision_id => $_[0], build_target => $_[1]};
-        }
-      }
-    },
-
     # Bug permission checks
     qr{^/phabbugz/check_bug/(\d+)/(\d+)$},
     {