diff --git a/cli/class-tmdo-cli.php b/cli/class-tmdo-cli.php index 48f044d..d87c79c 100644 --- a/cli/class-tmdo-cli.php +++ b/cli/class-tmdo-cli.php @@ -148,7 +148,8 @@ class TMDO_CLI { WP_CLI::log( 'Drift (last `wp tmdo drift-check` or daily sample):' ); foreach ( TMDO_Entity_Registry::VALID_ENTITY_TYPES as $entity_type ) { $groups = TMDO_Entity_Migration_Engine::backfillable_groups( $entity_type ); - $last = $status[ $entity_type ] ?? array(); + // Records of groups no longer registered can be neither re-checked nor fixed. + $last = array_intersect_key( (array) ( $status[ $entity_type ] ?? array() ), array_flip( $groups ) ); if ( empty( $groups ) || ( empty( $last ) && ! TMDO_Mode_Manager::writes_to_flat( $entity_type ) ) ) { continue; } diff --git a/tests/integration/DoctorTest.php b/tests/integration/DoctorTest.php index 14ef561..3a08d5f 100644 --- a/tests/integration/DoctorTest.php +++ b/tests/integration/DoctorTest.php @@ -98,6 +98,34 @@ class DoctorTest extends TestCase { $this->assertStringContainsString( 'wp tmdo drift-check user --fix', $this->cli_output() ); } + public function test_ignores_the_record_of_a_group_no_longer_registered(): void { + $GLOBALS['_wp_options']['wpdo_bridge_modes'] = array( 'user' => 'dual_write' ); + $GLOBALS['_wp_options'][ TMDO_Drift_Check::OPTION ] = array( + 'user' => array( + 'dt_have' => array( + 'miss' => 0, + 'diff' => 0, + 'extra' => 0, + 'sample' => 0, + 'checked_at' => '2026-09-27 00:00:00', + ), + 'dt_gone' => array( + 'miss' => 3, + 'diff' => 0, + 'extra' => 0, + 'sample' => 0, + 'checked_at' => '2026-09-20 00:00:00', + ), + ), + ); + TMDO_Mode_Manager::reset_cache(); + + TMDO_CLI::report_guard_and_drift(); + + $this->assertStringContainsString( '[OK] user: 1 group(s) clean (oldest check 2026-09-27 00:00:00 UTC)', $this->cli_output() ); + $this->assertStringNotContainsString( 'dt_gone', $this->cli_output() ); + } + public function test_reports_an_entity_never_checked(): void { $GLOBALS['_wp_options']['wpdo_bridge_modes'] = array( 'user' => 'dual_write' ); TMDO_Mode_Manager::reset_cache();