Repository navigation
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Codecov Reportâ
All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## trunk #463 +/- ##
=========================================
Coverage 93.13% 93.14%
Complexity 1386 1386
=========================================
Files 60 60
Lines 4023 4024 +1
=========================================
+ Hits 3747 3748 +1
Misses 276 276
Flags with carried forward coverage won't be shown. Click here to find out more. â View full report in Codecov by Harness. ð New features to boost your workflow:
|
There was a problem hiding this comment.
ðĄ Changes recommended
The runtime cache flush lacks a capability check, causing diagnostics on every valid STDIO message with unsupported persistent cache backends without clearing the cache.
1 open issue
What changed in this PR
Addresses #462 by refreshing WordPressâs runtime object cache between requests in the long-lived wp mcp-adapter serve process, preventing stale database reads on sites without a persistent object cache.
Changes:
- Calls
wp_cache_flush_runtime()before processing each parsed STDIO request. - Adds a regression test that simulates an external database update and checks that subsequent requests see fresh values while preserving the selected user.
| File | Description |
|---|---|
tests/âphpunit/âUnit/âCli/âStdioServerBridgeTest.php |
Tests cache freshness and user identity across sequential requests. |
includes/âCli/âStdioServerBridge.php |
Adds runtime-cache flushing before request processing. |
Review effort: Balanced
|
|
||
| // Clear the process-local runtime object cache so long-lived STDIO sessions | ||
| // read fresh database state updated by other processes (HTTP, cron, WP-CLI). | ||
| wp_cache_flush_runtime(); |

Closes #462
wp mcp-adapter serveruns in a single long-lived PHP-CLI process. On sites without an external persistent object cache, WordPress keeps post, postmeta, usermeta, and option lookups in the in-memory$wp_object_cachefor the lifetime of the process, so updates made by other processes (HTTP requests, cron, another WP-CLI command) stay invisible to subsequent STDIO calls.This calls
wp_cache_flush_runtime()inStdioServerBridge::handle_request()before processing each request, so every STDIO request reads fresh database state while leaving persistent object caches untouched.Testing
StdioServerBridgeTest::test_handle_request_flushes_runtime_object_cache_between_requests()simulating an external DB update between twotools/callrequests on the same bridge instance.composer lint(PHPCS) andcomposer phpstanlocally with no errors.