feat(2meet-data-optimizer): backfill every registered user group with member-backfill --all

- member-backfill / member-audit take their groups from the registry (TMDO_Entity_Migration_Engine::backfillable_groups(), restored orphans excluded) instead of a hard-coded list that still named the never-registered `sso`; `--all` backfills every user group (R-2.1 had to use wp eval). TMDO_Post_Migration::backfillable_groups() now delegates to it.
- member-cutover checks the Mode_Manager result with is_wp_error(): a guarded or invalid transition used to crash with a fatal (WP_Error used as an array).
- Verify: CliMemberBackfillTest (--all and the orphan filter RED before; the --group case cannot fail under the non-throwing WP_CLI stub); dev36 `member-backfill --all --reset` 9 groups, 0 errors, checker user miss/diff/extra 0; `member-cutover --confirm` exits 1 with the Guard message, mode unchanged.
- PR: PR-068
This commit is contained in:
2026-09-26 23:30:28 +08:00
parent 7807eae957
commit 2022cf1d08
4 changed files with 132 additions and 34 deletions
@@ -386,6 +386,23 @@ final class TMDO_Entity_Migration_Engine {
);
}
/**
* Registered groups of an entity type that can be backfilled from native
* meta. Orphan groups restored from wpdo_registry_meta are left out: their
* values live only in the flat table, a backfill would wipe them.
*
* @return string[]
*/
public static function backfillable_groups( string $entity_type ): array {
$orphans = array();
foreach ( TMDO_Entity_Registry::get_restored_groups() as $restored ) {
if ( $entity_type === $restored['entity_type'] ) {
$orphans[] = $restored['group'];
}
}
return array_values( array_diff( TMDO_Entity_Registry::get_groups_for_type( $entity_type ), $orphans ) );
}
// ─────────────────────────────────────────────────────────
// 斷點管理
// ─────────────────────────────────────────────────────────
@@ -561,13 +561,7 @@ final class TMDO_Post_Migration {
* @return string[]
*/
public static function backfillable_groups(): array {
$orphans = array();
foreach ( TMDO_Entity_Registry::get_restored_groups() as $restored ) {
if ( self::ENTITY_TYPE === $restored['entity_type'] ) {
$orphans[] = $restored['group'];
}
}
return array_values( array_diff( TMDO_Entity_Registry::get_groups_for_type( self::ENTITY_TYPE ), $orphans ) );
return TMDO_Entity_Migration_Engine::backfillable_groups( self::ENTITY_TYPE );
}
/**