@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix an edge case when trying to pull duplicate refs via Doorkeeper

Summary:
Report from Asana. In some unclear circumstances, we my attempt to resolve duplicate refs which currently ends up hitting a duplicate key error.

Instead, reference the same external object if we happen to be handed duplicate refs.

Test Plan:
Used this script to reproduce the issue. Applied the fix; issue went away:

#!/usr/bin/env php
<?php

require_once 'scripts/__init_script__.php';

$args = new PhutilArgumentParser($argv);
$args->parseStandardArguments();

$ref = id(new DoorkeeperObjectRef())
->setApplicationType(DoorkeeperBridgeAsana::APPTYPE_ASANA)
->setApplicationDomain(DoorkeeperBridgeAsana::APPDOMAIN_ASANA)
->setObjectType(DoorkeeperBridgeAsana::OBJTYPE_TASK)
->setObjectID(7253737283629); // Use a new task ID which we've never pulled.

$refs = array(clone $ref, clone $ref);

$asana_user = id(new PhabricatorPeopleQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
->withUsernames(array('asana'))
->executeOne();

$resolved_refs = id(new DoorkeeperImportEngine())
->setViewer($asana_user)
->setRefs($refs)
->execute();

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D7709

+6
+6
src/applications/doorkeeper/engine/DoorkeeperImportEngine.php
··· 53 53 $xobj = $ref 54 54 ->newExternalObject() 55 55 ->setImporterPHID($viewer->getPHID()); 56 + 57 + // NOTE: Fill the new external object into the object map, so we'll 58 + // reference the same external object if more than one ref is the 59 + // same. This prevents issues later where we double-populate 60 + // external objects when handed duplicate refs. 61 + $xobjs[$ref->getObjectKey()] = $xobj; 56 62 } 57 63 $ref->attachExternalObject($xobj); 58 64 }