diff --git a/app/src/Lib/Traits/EntityMetaTrait.php b/app/src/Lib/Traits/EntityMetaTrait.php index 5cb4c3b13..bd8d7ddf3 100644 --- a/app/src/Lib/Traits/EntityMetaTrait.php +++ b/app/src/Lib/Traits/EntityMetaTrait.php @@ -62,7 +62,8 @@ public function isProbablyThisArray(array $data): bool { foreach($data as $field => $value) { if((!isset($this->$field) && !empty($value)) // Value in $data but not $entity - || (isset($this->$field) && empty($value)) // Value in $entity but not $data + || (isset($this->$field) && empty($value) // Value in $entity but not $data + && !empty($this->$field)) // ... and $entity is not falsey || (isset($this->$field) && $this->$field != $value)) { // Values don't match // Not a match $match = false; diff --git a/app/src/Model/Table/PipelinesTable.php b/app/src/Model/Table/PipelinesTable.php index c5df4f4dd..32f088a1d 100644 --- a/app/src/Model/Table/PipelinesTable.php +++ b/app/src/Model/Table/PipelinesTable.php @@ -418,6 +418,14 @@ protected function duplicateFilterEntityData($entity): array { $newdata['status'] ); + // Timestamps are FrozenTime objects in the entity data, and is_scalar + // will filter them out, so convert them to strings + foreach(['valid_from', 'valid_through'] as $attr) { + if(!empty($entity->$attr)) { + $newdata[$attr] = $entity->$attr->i18nFormat('yyyy-MM-dd HH:mm:ss'); + } + } + // This will remove anything that isn't stringy return array_filter($newdata, 'is_scalar'); } @@ -1269,14 +1277,20 @@ protected function syncExternalIdentity( // $arecord should include the associated models, so we don't need // to do any special handling for them. + $associated = []; + + if($model == 'ExternalIdentityRoles') { + $associated = ['Addresses', 'AdHocAttributes', 'TelephoneNumbers']; + } + $newentity = $this->Cos->People->ExternalIdentities->$model->newEntity( $arecord, - ['associated' => ['Addresses', 'AdHocAttributes', 'TelephoneNumbers']] + ['associated' => $associated] ); $this->Cos->People->ExternalIdentities->$model->saveOrFail( $newentity, - ['associated' => ['Addresses', 'AdHocAttributes', 'TelephoneNumbers']] + ['associated' => $associated] ); $this->llog('trace', "Added $model " . $newentity->id . " for External Identity " . $externalIdentityEntity->id);