Skip to content

Commit

Permalink
Fix external identity sources status/sync_mode transmogrification
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Dec 19, 2025
1 parent 3917640 commit 10fc805
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/plugins/Transmogrify/config/schema/tables.json
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@
"plugin": "&mapExternalIdentitySourcePlugin",
"co_pipeline_id": "pipeline_id",
"org_identity_source_id": "external_identity_source_id",
"status": "&mapStatusAndSyncToStatus",
"sync_mode": null,
"sync_query_mismatch_mode": null,
"sync_query_skip_known": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ public function execute(Arguments $args, ConsoleIo $io): int
return BaseCommand::CODE_ERROR;
}


// Execute any pre-processing hooks for the current table
$this->runPreTableHook($t);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ private function applyDefaultIfNull(array &$row, string $oldname, string $defaul
}
}


/**
* Rename a field by copying its value to a new key and removing the old key.
*
Expand Down
49 changes: 49 additions & 0 deletions app/plugins/Transmogrify/src/Lib/Traits/TypeMapperTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
namespace Transmogrify\Lib\Traits;

use App\Lib\Enum\PetitionStatusEnum;
use App\Lib\Enum\SyncModeEnum;
use Cake\ORM\TableRegistry;
use Cake\Utility\Hash;
use Cake\Utility\Inflector;
Expand Down Expand Up @@ -820,6 +821,54 @@ protected function mapPersonStatus(array $row): ?string
}


/**
* Maps v4 status/sync_mode combination to v5 status values
*
* v4:
* - status: 'A' (active) or 'S' (suspended)
* - sync_mode: 'F' (Full), 'M' (Manual), 'Q' (Query), 'U' (Update)
*
* v5:
* - sync_mode and status are merged into the single "status" column
* - "Active" is no longer a separate thing
* - v4 suspended ('S') becomes v5 Disabled ('X')
*
* Logic:
* - If v4 status is suspended ('S'), always map to Disabled.
* - Otherwise, copy the sync_mode over:
* F -> Full
* M -> Manual
* U -> Update
* Q -> Disabled (not yet supported; see CFM-372).
*
* @param array $row Row data containing 'status' and 'sync_mode' fields from v4
* @return string|null Mapped v5 status value or null if sync_mode missing/empty
* @since COmanage Registry v5.2.0
*/
protected function mapStatusAndSyncToStatus(array $row): ?string
{
$v4Status = $row['status'] ?? null;
$v4SyncMode = $row['sync_mode'] ?? null;

// Suspended in v4 becomes Disabled in v5
if ($v4Status === 'S') {
return SyncModeEnum::Disabled;
}

if ($v4SyncMode === null || $v4SyncMode === '') {
return null;
}

return match ($v4SyncMode) {
'F' => SyncModeEnum::Full,
'M' => SyncModeEnum::Manual,
'U' => SyncModeEnum::Update,
'Q' => SyncModeEnum::Disabled, // XXX not yet supported; see CFM-372
default => null,
};
}


/**
* Map server type code to corresponding plugin path
*
Expand Down

0 comments on commit 10fc805

Please sign in to comment.