diff options
author | Dylan William Hardison <dylan@hardison.net> | 2017-12-05 15:16:03 +0100 |
---|---|---|
committer | Dylan William Hardison <dylan@hardison.net> | 2017-12-05 15:17:21 +0100 |
commit | 83bc5b8c30a68203bc073b82be06585b7b6bd799 (patch) | |
tree | cd9b12d70bc36b6ac377d4123a05a972a1d3469e /extensions | |
parent | 3e07c354707f39dbc26cecbbc8cdf9c70879e70c (diff) | |
download | bugzilla-83bc5b8c30a68203bc073b82be06585b7b6bd799.tar.gz bugzilla-83bc5b8c30a68203bc073b82be06585b7b6bd799.tar.xz |
Revert "Bug 1422329 - The phabricator conduit API method feed.query_id return data format has changed so the phabbugz_feed.pl daemon needs to be updated"
This reverts commit 357528ba856fd85aee5967e5d7d8f4426bc8d5b6.
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/PhabBugz/lib/Feed.pm | 26 | ||||
-rw-r--r-- | extensions/PhabBugz/lib/Revision.pm | 4 | ||||
-rw-r--r-- | extensions/PhabBugz/lib/Util.pm | 4 |
3 files changed, 21 insertions, 13 deletions
diff --git a/extensions/PhabBugz/lib/Feed.pm b/extensions/PhabBugz/lib/Feed.pm index b2b681bbd..d178f249b 100644 --- a/extensions/PhabBugz/lib/Feed.pm +++ b/extensions/PhabBugz/lib/Feed.pm @@ -76,7 +76,7 @@ sub feed_query { foreach my $story_data (@$transactions) { my $skip = 0; my $story_id = $story_data->{id}; - my $story_phid = $story_data->{phid}; + my $story_phid = $story_data->{storyPHID}; my $author_phid = $story_data->{authorPHID}; my $object_phid = $story_data->{objectPHID}; my $story_text = $story_data->{text}; @@ -296,13 +296,25 @@ sub feed_transactions { my $data = { view => 'text' }; $data->{after} = $after if $after; my $result = request('feed.query_id', $data); - unless (ref $result->{result}{data} eq 'ARRAY' - && @{ $result->{result}{data} }) - { - return []; + + # Stupid Conduit. If the feed results are empty it returns + # an empty list ([]). If there is data it returns it in a + # hash ({}) so we have adjust to be consistent. + my $stories = ref $result->{result}{data} eq 'HASH' + ? $result->{result}{data} + : {}; + + # PHP array retain key order but Perl does not. So we will + # loop over the data and place the stories into a list instead + # of a hash. We will then sort the list by id. + my @story_list; + foreach my $story_phid (keys %$stories) { + my $story_data = $stories->{$story_phid}; + $story_data->{storyPHID} = $story_phid; + push(@story_list, $story_data); } - # Guarantee that the data is in ascending ID order - return [ sort { $a->{id} <=> $b->{id} } @{ $result->{result}{data} } ]; + + return [ sort { $a->{id} <=> $b->{id} } @story_list ]; } 1; diff --git a/extensions/PhabBugz/lib/Revision.pm b/extensions/PhabBugz/lib/Revision.pm index f3a56a656..29d665009 100644 --- a/extensions/PhabBugz/lib/Revision.pm +++ b/extensions/PhabBugz/lib/Revision.pm @@ -30,11 +30,7 @@ my $SearchResult = Dict[ authorPHID => Str, dateCreated => Int, dateModified => Int, - diffPHID => Str, policy => Dict[ view => Str, edit => Str ], - repositoryPHID => Maybe[Str], - status => HashRef, - summary => Str, "bugzilla.bug-id" => Int, ], attachments => Dict[ diff --git a/extensions/PhabBugz/lib/Util.pm b/extensions/PhabBugz/lib/Util.pm index 1f2b21d55..a00e20551 100644 --- a/extensions/PhabBugz/lib/Util.pm +++ b/extensions/PhabBugz/lib/Util.pm @@ -327,7 +327,7 @@ sub get_members_by_bmo_id { my $result = get_phab_bmo_ids({ ids => [ map { $_->id } @$users ] }); my @phab_ids; - foreach my $user (@$result) { + foreach my $user (@{ $result->{result} }) { push(@phab_ids, $user->{phid}) if ($user->{phid} && $user->{phid} =~ /^PHID-USER/); } @@ -341,7 +341,7 @@ sub get_members_by_phid { my $result = get_phab_bmo_ids({ phids => $phids }); my @bmo_ids; - foreach my $user (@$result) { + foreach my $user (@{ $result->{result} }) { push(@bmo_ids, $user->{id}) if ($user->{phid} && $user->{phid} =~ /^PHID-USER/); } |