Homec4science

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

Authored by epriestley <git@epriestley.com> on Dec 5 2013, 20:45.

Description

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

Details

Committed
epriestley <git@epriestley.com>Dec 5 2013, 20:45
Pushed
aubortJan 31 2017, 17:16
Parents
rPHea1d4ff70d58: Add background color to ObjectList when in an ObjectBox
Branches
Unknown
Tags
Unknown

Event Timeline

epriestley <git@epriestley.com> committed rPHc6fd969416a5: Fix an edge case when trying to pull duplicate refs via Doorkeeper (authored by epriestley <git@epriestley.com>).Dec 5 2013, 20:45