Preload REST API responses for plugins on Connectors screen and add support for preloading non-OK responses#11790
Preload REST API responses for plugins on Connectors screen and add support for preloading non-OK responses#11790westonruter wants to merge 7 commits into
Conversation
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
" This reverts commit 0065b16.
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Trac ticket: https://core.trac.wordpress.org/ticket/65215
This backports the logic in this Gutenberg PR, which also must be applied to core to see the preloading take effect on the Connectors screen:
Additionally, improves REST API preloading in a few ways ways:
First of all, support is added to allow a non-OK response for a preloaded request to be sent to the preloading middleware. Without this, all of the plugins on the Connectors screen would cause unconditional 404 REST API responses when accessing the page:
The data format for a preloaded request was previously two possibilities:
string: The REST API path to preload.array{ 0: string, 1?: 'OPTIONS'|'GET' }. A tuple with the first item being the REST API path, and the second item being the method.This PR modifies the tuple to add a third item for the
allowed_statuses:This allows us now to do the following:
This allows both
200 OKresponses and404 Not Foundresponses to be served to the preload middleware. If this 3rd item of the tuple is omitted, then it retains the previous behavior of only allowing200 OK.To further support this enhancement, full PHPStan typing was added to the
rest_preload_api_request()function, and any PHPStan rule level 10 errors were addressed:Use of AI Tools
AI assistance: Yes
Tool(s): Clause Code
Model(s): Claude Opus 4.7
Used for: Research for PHPStan types.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.