fix(2meet-data-optimizer): forget post status columns of groups whose flat table is gone
- on_transition() skips a recorded group whose table no longer exists and removes it from tmdo_post_status_columns; every post status change used to UPDATE the missing table and print a database error (seen on dev36 after a throwaway group's table was dropped) - Verify: PostStatusSyncTest (dropped table), integration 578, unit 701, phpcs, stan - PR: PR-106
This commit is contained in:
@@ -134,6 +134,23 @@ class PostStatusSyncTest extends TestCase {
|
||||
$this->assertSame( array( 'draft', '2026-02-01 10:00:00' ), $this->copies( self::A )[2], 'other posts untouched' );
|
||||
}
|
||||
|
||||
public function test_a_group_whose_table_was_dropped_is_forgotten(): void {
|
||||
global $wpdb;
|
||||
TMDO_Post_Status_Sync::run();
|
||||
$wpdb->query( 'DROP TABLE `' . self::B . '`' );
|
||||
$ref = new ReflectionProperty( WPDO_Schema_Manager::class, 'table_exists_cache' );
|
||||
$ref->setAccessible( true );
|
||||
$ref->setValue( null, array() );
|
||||
$wpdb->last_error = '';
|
||||
|
||||
TMDO_Post_Status_Sync::on_transition( 'trash', 'publish', (object) array( 'ID' => 1, 'post_status' => 'trash', 'post_date' => '2026-01-05 00:00:00' ) );
|
||||
|
||||
$this->assertSame( '', (string) $wpdb->last_error, 'no UPDATE of a missing table' );
|
||||
$this->assertSame( '', TMDO_Post_Status_Sync::state( 'ps_b' ), 'forgotten' );
|
||||
$this->assertSame( 'ready', TMDO_Post_Status_Sync::state( 'ps_a' ) );
|
||||
$this->assertSame( array( 'trash', '2026-01-05 00:00:00' ), $this->copies( self::A )[1] );
|
||||
}
|
||||
|
||||
public function test_transition_leaves_tables_without_the_columns_alone(): void {
|
||||
global $wpdb;
|
||||
$wpdb->last_error = '';
|
||||
|
||||
Reference in New Issue
Block a user