Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CO-2774_Internal_Error_when_linking_an_Org_Identity_to_a_CO_Person #692

Open
wants to merge 1 commit into
base: hotfix-4.4.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions app/Lib/CoHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,25 @@
class CoHttpClient extends HttpSocket {
protected $_baseUrl = null;
protected $_requestOptions = array();



/**
* CoHttpClient constructor.
*
* @param array $config Configuration options for the HttpClient.
*/
public function __construct($config = array())
{
if (!isset($config['timeout'])) {
// Initialize default values
// Set the default timeout to 5 seconds instead of 30.
$config['timeout'] = 5;
}
// Call the parent constructor
parent::__construct($config);

}

/**
* Build a URL using the configured base URL.
*
Expand Down Expand Up @@ -189,11 +207,15 @@ public function setConfig($config) {
}

if(isset($config['ssl_verify_host'])) {
$this->config['ssl_verify_host'];
$this->config['ssl_verify_host'] = $config['ssl_verify_host'];
}

if(isset($config['ssl_verify_peer'])) {
$this->config['ssl_verify_peer'];
$this->config['ssl_verify_peer'] = $config['ssl_verify_peer'];
}

if(isset($config['timeout'])) {
$this->config['timeout'] = $config['timeout'];
}
}

Expand Down
38 changes: 21 additions & 17 deletions app/Model/CoPipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,25 +309,29 @@ public function execute($id, $orgIdentityId, $syncAction, $actorCoPersonId=null,
($syncAction == SyncActionEnum::Delete && !$pipeline['CoPipeline']['sync_on_delete'])) {
return true;
}

// We need to find a CO Person to operate on.
$targetIds = $this->findTargetCoPersonId($pipeline, $orgIdentityId, $actorCoPersonId);

if(!$targetIds['co_person_id']) {
// What we do here depends on the sync action. On add, we create a new CO Person.
// On update, we do not and abort. This will be a bit confusing if something goes wrong
// during an initial add, but short of a "force" (manual operation), there's
// not much else to do. On delete we also abort.

if($syncAction != SyncActionEnum::Add) {
// If we don't have a CO Person record on an update or delete, there's
// nothing to do. For relink, we expect the new target to already exist.
// (Relink to a "new" person should be submitted as an Add, since if
// "sync on add" is disabled we shouldn't create a new CO Person.)
return true;

// `findTargetCoPersonId` will try to save a new Link if the requirements are met. During
// an unlink action this will create a loop and it will eventually fail.
if ($syncAction !== SyncActionEnum::Unlink) {
// We need to find a CO Person to operate on.
$targetIds = $this->findTargetCoPersonId($pipeline, $orgIdentityId, $actorCoPersonId);
if(!$targetIds['co_person_id']) {
// What we do here depends on the sync action. On add, we create a new CO Person.
// On update, we do not and abort. This will be a bit confusing if something goes wrong
// during an initial add, but short of a "force" (manual operation), there's
// not much else to do. On delete we also abort.

if($syncAction != SyncActionEnum::Add) {
// If we don't have a CO Person record on an update or delete, there's
// nothing to do. For relink, we expect the new target to already exist.
// (Relink to a "new" person should be submitted as an Add, since if
// "sync on add" is disabled we shouldn't create a new CO Person.)
return true;
}
}

}

if(($syncAction == SyncActionEnum::Delete
&& !empty($pipeline['CoPipeline']['sync_status_on_delete']))
|| $syncAction == SyncActionEnum::Unlink) {
Expand Down