From 0fe18f5460d7e3a2b2a83372308e540ba5da7722 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sat, 13 Jul 2013 10:41:23 -0700 Subject: [PATCH] Fix two problems with actor order in Asana bridge Summary: We attempt to choose the most reasonable actor when synchronizing to Asana, but Asana is seeing the sync choose a less-reasonable actor. I spotted two places where the order may get disrupted; make sure we retain order. This is somewhat tricky to repro locally (it depends on things like native account order) but I think this is the right fix. If not, I'll add more logging. Ref T2852. Test Plan: Used `bin/feed republish` to sync Asana events. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2852 Differential Revision: https://secure.phabricator.com/D6443 --- .../worker/DoorkeeperFeedWorkerAsana.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/applications/doorkeeper/worker/DoorkeeperFeedWorkerAsana.php b/src/applications/doorkeeper/worker/DoorkeeperFeedWorkerAsana.php index 5304115cd6..3946f21bbb 100644 --- a/src/applications/doorkeeper/worker/DoorkeeperFeedWorkerAsana.php +++ b/src/applications/doorkeeper/worker/DoorkeeperFeedWorkerAsana.php @@ -163,6 +163,8 @@ final class DoorkeeperFeedWorkerAsana extends FeedPushWorker { $object = $this->getStoryObject(); $src_phid = $object->getPHID(); + $chronological_key = $story->getChronologicalKey(); + if (!$this->isObjectSupported($object)) { $this->log("Story is about an unsupported object type.\n"); return; @@ -189,8 +191,10 @@ final class DoorkeeperFeedWorkerAsana extends FeedPushWorker { $follow_phids); $all_follow_phids = array_unique(array_filter($all_follow_phids)); - $all_phids = $all_follow_phids; - $all_phids[] = $owner_phid; + $all_phids = array(); + $all_phids = array_merge( + array($owner_phid), + $all_follow_phids); $all_phids = array_unique(array_filter($all_phids)); $phid_aid_map = $this->lookupAsanaUserIDs($all_phids); @@ -537,6 +541,12 @@ final class DoorkeeperFeedWorkerAsana extends FeedPushWorker { ->withAccountDomains(array($provider->getProviderDomain())) ->execute(); + // Reorder accounts in the original order. + // TODO: This needs to be adjusted if/when we allow you to link multiple + // accounts. + $accounts = mpull($accounts, null, 'getUserPHID'); + $accounts = array_select_keys($accounts, $user_phids); + $workspace_id = $this->getWorkspaceID(); foreach ($accounts as $account) {