summaryrefslogtreecommitdiffstats
path: root/extensions/PhabBugz/lib/Feed.pm
diff options
context:
space:
mode:
authorDavid Lawrence <dkl@mozilla.com>2017-12-19 05:28:51 +0100
committerDylan William Hardison <dylan@hardison.net>2017-12-19 06:24:02 +0100
commit6bcedf7e2cb411174220bff87e2c8318a210ce48 (patch)
tree28b42a1af9bb30de83d0a0eb0b99db0300f309c1 /extensions/PhabBugz/lib/Feed.pm
parentc1c8739bb0a2eaf98ddaa2824abf4a048f209216 (diff)
downloadbugzilla-6bcedf7e2cb411174220bff87e2c8318a210ce48.tar.gz
bugzilla-6bcedf7e2cb411174220bff87e2c8318a210ce48.tar.xz
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
Diffstat (limited to 'extensions/PhabBugz/lib/Feed.pm')
-rw-r--r--extensions/PhabBugz/lib/Feed.pm26
1 files changed, 7 insertions, 19 deletions
diff --git a/extensions/PhabBugz/lib/Feed.pm b/extensions/PhabBugz/lib/Feed.pm
index d178f249b..b2b681bbd 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->{storyPHID};
+ my $story_phid = $story_data->{phid};
my $author_phid = $story_data->{authorPHID};
my $object_phid = $story_data->{objectPHID};
my $story_text = $story_data->{text};
@@ -296,25 +296,13 @@ sub feed_transactions {
my $data = { view => 'text' };
$data->{after} = $after if $after;
my $result = request('feed.query_id', $data);
-
- # 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);
+ unless (ref $result->{result}{data} eq 'ARRAY'
+ && @{ $result->{result}{data} })
+ {
+ return [];
}
-
- return [ sort { $a->{id} <=> $b->{id} } @story_list ];
+ # Guarantee that the data is in ascending ID order
+ return [ sort { $a->{id} <=> $b->{id} } @{ $result->{result}{data} } ];
}
1;