diff --git a/app/resources/locales/en_US/defaultType.po b/app/resources/locales/en_US/defaultType.po index ee6498f0f..4c08dc2d7 100644 --- a/app/resources/locales/en_US/defaultType.po +++ b/app/resources/locales/en_US/defaultType.po @@ -106,8 +106,9 @@ msgstr "SAML Pairwise" msgid "Identifiers.type.subjectid" msgstr "SAML Subject" +# Because this was called "sorid" in v4, we keep that as the internal key msgid "Identifiers.type.sorid" -msgstr "System of Record" +msgstr "Source Key" msgid "Identifiers.type.uid" msgstr "UID" diff --git a/app/src/Model/Table/ExternalIdentitySourcesTable.php b/app/src/Model/Table/ExternalIdentitySourcesTable.php index 345eed39a..d8e7615af 100644 --- a/app/src/Model/Table/ExternalIdentitySourcesTable.php +++ b/app/src/Model/Table/ExternalIdentitySourcesTable.php @@ -234,6 +234,11 @@ public function retrieve(int $id, string $sourceKey): array { // Inject the source key so every backend doesn't have to do this $record['entity_data']['source_key'] = $sourceKey; + $record['entity_data']['identifiers'][] = [ + 'identifier' => $sourceKey, + 'type' => 'sorid' + ]; + return $record; } diff --git a/app/src/Model/Table/PipelinesTable.php b/app/src/Model/Table/PipelinesTable.php index f3471e96d..94213d9e4 100644 --- a/app/src/Model/Table/PipelinesTable.php +++ b/app/src/Model/Table/PipelinesTable.php @@ -1187,7 +1187,8 @@ protected function syncExternalIdentity( // We do rely on this block to process EIR related models, // which have roleIdentifiers that allow us to match records. - foreach($externalIdentity->$amodel as $aentity) { + // $akey is just the index into the array + foreach($externalIdentity->$amodel as $akey => $aentity) { if($aentity->id == $arecord['id']) { // This is the record we mapped in the backend data $this->Cos->People->ExternalIdentities->$model->patchEntity( @@ -1217,7 +1218,7 @@ protected function syncExternalIdentity( $aeirmodel = Inflector::underscore($eirmodel); if(!empty($arecord[$aeirmodel])) { - // We have one or more Role related model is the mapped + // We have one or more Role related model in the mapped // backend data, check for update vs insert. foreach($arecord[$aeirmodel] as $aeirrecord) { @@ -1251,9 +1252,13 @@ protected function syncExternalIdentity( $this->Cos->People->ExternalIdentities->$model->$eirmodel->saveOrFail($newentity); $this->llog('trace', "Added $eirmodel " . $newentity->id . " for $model " . $aentity->id); - // Inject the new entity so syncPerson sees it - $externalIdentity->$model->$eirmodel[] = $newentity; - $newEntities[$amodel][] = $newentity->id; + // Inject the new entity so syncPerson sees it. + // Note that $externalIdentity->$amodel is an array + // of ExternalIdentityRoles, so we need to attach the + // related model entity to the correct role. + + $externalIdentity->$amodel[$akey]->$aeirmodel[] = $newentity; + $newEntities[$aeirmodel][] = $newentity->id; } } }