Skip to content

Commit

Permalink
Fix broken OrgIdentity Linking
Browse files Browse the repository at this point in the history
  • Loading branch information
ioigoume committed Feb 18, 2025
1 parent d4a307b commit 102d63b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 20 deletions.
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

0 comments on commit 102d63b

Please sign in to comment.