Skip to content

Commit

Permalink
Additional Pipeline fix (NOJIRA)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benn Oshrin committed Aug 29, 2024
1 parent 8e283ca commit 2573f9c
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions app/src/Model/Table/PipelinesTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,9 @@ protected function duplicateFilterEntityData($entity): array {
foreach(['valid_from', 'valid_through'] as $attr) {
if(!empty($entity->$attr)) {
$newdata[$attr] = $entity->$attr->i18nFormat('yyyy-MM-dd HH:mm:ss');
} else {
// Populate a blank value so removal works correctly
} elseif(isset($entity->$attr)) {
// Populate a blank value so removal works correctly (but don't inject
// the fields to models that don't have them)
$newdata[$attr] = "";
}
}
Expand Down Expand Up @@ -1496,7 +1497,7 @@ protected function syncPerson(
// sourceModel = eg SourceName
$sourceModel = StringUtilities::foreignKeyToClassName($sourcefk);
// sourceEntity = eg source_name
$sourceEntity = "source_" . $amodel;
$sourceEntity = "source_" . Inflector::singularize($amodel);

// Pull the current set of associated records for this model.
// We can filter down to those that came from _any_ source (ie
Expand Down Expand Up @@ -1600,13 +1601,28 @@ protected function syncPerson(

if(!empty($curentities)) {
foreach($curentities as $aentity) {
if(!empty($aentity->$sourceEntity->external_identity_id)
&& $aentity->$sourceEntity->external_identity_id == $externalIdentityId) {
// $aentity is an entity attached to the Person and was sourced from
// an attribute associated with the current External Identity (as opposed
// to another EI associated with the Person); we search through the
// source attributes for one with a corresponding source key ID
$found = Hash::extract($externalIdentity[$amodel], '{n}[id='.$aentity->$sourcefk.']');
if(!empty($aentity->$sourcefk)) {
$found = false;

if(!empty($aentity->$sourceEntity->external_identity_id)) {
// This is a sourced attribute associated with an External Identity,
// only process if it's the External Identity we're currently working with

if($aentity->$sourceEntity->external_identity_id == $externalIdentityId) {
// $aentity is an entity attached to the Person and was sourced from
// an attribute associated with the current External Identity (as opposed
// to another EI associated with the Person); we search through the
// source attributes for one with a corresponding source key ID.
$found = Hash::extract($externalIdentity[$amodel], '{n}[id='.$aentity->$sourcefk.']');
} else {
// This doesn't belong to our current External Identity, so flag it as
// "found" so we don't delete it
$found = true;
}
} else {
// This is probably a deleted attribute on the EI that the Person attribute
// still points to. Clean it up.
}

if(!$found) {
if(isset($aentity->frozen) && $aentity->frozen) {
Expand All @@ -1617,6 +1633,7 @@ protected function syncPerson(
}
}
}
// else this is a manual attribute, ignore it
}
}
}
Expand Down

0 comments on commit 2573f9c

Please sign in to comment.