From feac63173b7bc43b45cb7adc7c7e23363162da84 Mon Sep 17 00:00:00 2001 From: wpdev Date: Fri, 31 Jul 2026 05:56:36 +0800 Subject: [PATCH] =?UTF-8?q?test(migration):=20PostMigrationTest=20/=20Post?= =?UTF-8?q?EntityLifecycleTest=20=E8=A3=9C=20flush=5Ftable=5Fexists=5Fcach?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 引入 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 Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY --- tests/integration/PostEntityLifecycleTest.php | 4 ++++ tests/integration/PostMigrationTest.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/tests/integration/PostEntityLifecycleTest.php b/tests/integration/PostEntityLifecycleTest.php index 345e89c..097c951 100644 --- a/tests/integration/PostEntityLifecycleTest.php +++ b/tests/integration/PostEntityLifecycleTest.php @@ -150,6 +150,10 @@ class PostEntityLifecycleTest extends TestCase { $wpdb->query( 'TRUNCATE TABLE `' . self::POSTS . '`' ); $wpdb->query( 'TRUNCATE TABLE `' . self::POSTMETA . '`' ); $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 { diff --git a/tests/integration/PostMigrationTest.php b/tests/integration/PostMigrationTest.php index f10edef..164a118 100644 --- a/tests/integration/PostMigrationTest.php +++ b/tests/integration/PostMigrationTest.php @@ -114,6 +114,10 @@ class PostMigrationTest extends TestCase { $wpdb->query( 'TRUNCATE TABLE `' . self::POSTS . '`' ); $wpdb->query( 'TRUNCATE TABLE `' . self::POSTMETA . '`' ); $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 {