test(migration): PostMigrationTest / PostEntityLifecycleTest 補 flush_table_exists_cache

引入 table_exists request-scoped cache 後,其他測試類建立/drop 的 sibling
flat 表(wpdo_post_attachment)會在快取留下 stale true,diagnose() 於是
去 COUNT 一張已被 drop 的表 → mysqli_sql_exception。

A 在 v3.4.6 踩過同一個坑,修法相同:兩個測試的 setUp 呼叫
Schema_Manager::flush_table_exists_cache()。

unit 451 / integration 398 GREEN

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
This commit is contained in:
2026-07-31 05:56:36 +08:00
parent c46814ce83
commit feac63173b
2 changed files with 8 additions and 0 deletions
@@ -150,6 +150,10 @@ class PostEntityLifecycleTest extends TestCase {
$wpdb->query( 'TRUNCATE TABLE `' . self::POSTS . '`' ); $wpdb->query( 'TRUNCATE TABLE `' . self::POSTS . '`' );
$wpdb->query( 'TRUNCATE TABLE `' . self::POSTMETA . '`' ); $wpdb->query( 'TRUNCATE TABLE `' . self::POSTMETA . '`' );
$wpdb->query( 'TRUNCATE TABLE `' . self::FLAT . '`' ); $wpdb->query( 'TRUNCATE TABLE `' . self::FLAT . '`' );
// Other classes create/drop sibling flat tables (e.g. wpdo_post_attachment):
// a stale table_exists() cache would make diagnose() COUNT a dropped table.
TMDO_Schema_Manager::flush_table_exists_cache();
} }
private static function class_for( string $rel ): ?string { private static function class_for( string $rel ): ?string {
+4
View File
@@ -114,6 +114,10 @@ class PostMigrationTest extends TestCase {
$wpdb->query( 'TRUNCATE TABLE `' . self::POSTS . '`' ); $wpdb->query( 'TRUNCATE TABLE `' . self::POSTS . '`' );
$wpdb->query( 'TRUNCATE TABLE `' . self::POSTMETA . '`' ); $wpdb->query( 'TRUNCATE TABLE `' . self::POSTMETA . '`' );
$wpdb->query( 'TRUNCATE TABLE `' . self::FLAT . '`' ); $wpdb->query( 'TRUNCATE TABLE `' . self::FLAT . '`' );
// Other classes create/drop sibling flat tables (e.g. wpdo_post_attachment):
// a stale table_exists() cache would make diagnose() COUNT a dropped table.
TMDO_Schema_Manager::flush_table_exists_cache();
} }
private function seed_post( int $id, string $post_type ): void { private function seed_post( int $id, string $post_type ): void {