fix(2meet-data-optimizer): doctor ignores drift records of groups no longer registered
- A group's last drift record outlived its registration (wc_product and user hot on dev36, any add-on deactivated): doctor counted it and could warn forever with a --fix hint that cannot reach it. Only records of backfillable groups are read; the router and clean_since already go by the registry. - Verify: DoctorTest (RED before); dev36 doctor user 9 → 8 groups - PR: PR-089a
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user