hardening 2.2: 2meet-data-optimizer 1.2.0 (drift detection, scope, CLI and diagnostics) #6
@@ -148,7 +148,8 @@ class TMDO_CLI {
|
|||||||
WP_CLI::log( 'Drift (last `wp tmdo drift-check` or daily sample):' );
|
WP_CLI::log( 'Drift (last `wp tmdo drift-check` or daily sample):' );
|
||||||
foreach ( TMDO_Entity_Registry::VALID_ENTITY_TYPES as $entity_type ) {
|
foreach ( TMDO_Entity_Registry::VALID_ENTITY_TYPES as $entity_type ) {
|
||||||
$groups = TMDO_Entity_Migration_Engine::backfillable_groups( $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 ) ) ) {
|
if ( empty( $groups ) || ( empty( $last ) && ! TMDO_Mode_Manager::writes_to_flat( $entity_type ) ) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,6 +98,34 @@ class DoctorTest extends TestCase {
|
|||||||
$this->assertStringContainsString( 'wp tmdo drift-check user --fix', $this->cli_output() );
|
$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 {
|
public function test_reports_an_entity_never_checked(): void {
|
||||||
$GLOBALS['_wp_options']['wpdo_bridge_modes'] = array( 'user' => 'dual_write' );
|
$GLOBALS['_wp_options']['wpdo_bridge_modes'] = array( 'user' => 'dual_write' );
|
||||||
TMDO_Mode_Manager::reset_cache();
|
TMDO_Mode_Manager::reset_cache();
|
||||||
|
|||||||
Reference in New Issue
Block a user