Move HttpTransport hook registration to boot()#222
Conversation
Add boot() to McpTransportInterface so transports register WordPress hooks after construction. McpTransportFactory calls boot() immediately after instantiation. Closes WordPress#52.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the 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. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## trunk #222 +/- ##
=========================================
Coverage 87.86% 87.86%
- Complexity 1245 1246 +1
=========================================
Files 53 53
Lines 4037 4039 +2
=========================================
+ Hits 3547 3549 +2
Misses 490 490
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:
|
Summary
Follow-up to #52 (review comment on #48): HttpTransport no longer registers
est_api_init in its constructor.
boot()toMcpTransportInterfacefor WordPress hook registration after constructionMcpTransportFactorycallsboot()immediately after instantiating each transportHttpTransport::boot()keeps the existingrest_api_initpriority (16) behaviorMotivation
Constructors should set up dependencies only; hook registration is explicit and easier to test in isolation. Happy to adjust naming or scope if maintainers prefer a lighter-touch approach (e.g. factory-only hook without an interface change).
Closes #52
Test plan
HttpTransportBootTestconfirms the constructor does not register hooks andboot()registersrest_api_initat priority 16rest_url( 'mcp/mcp-adapter-default-server' ))