mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-01 01:18:22 +01:00
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
This commit is contained in:
parent
ea1d4ff70d
commit
c6fd969416
1 changed files with 6 additions and 0 deletions
|
@ -53,6 +53,12 @@ final class DoorkeeperImportEngine extends Phobject {
|
|||
$xobj = $ref
|
||||
->newExternalObject()
|
||||
->setImporterPHID($viewer->getPHID());
|
||||
|
||||
// NOTE: Fill the new external object into the object map, so we'll
|
||||
// reference the same external object if more than one ref is the
|
||||
// same. This prevents issues later where we double-populate
|
||||
// external objects when handed duplicate refs.
|
||||
$xobjs[$ref->getObjectKey()] = $xobj;
|
||||
}
|
||||
$ref->attachExternalObject($xobj);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue