Opened 6 years ago
Closed 6 years ago
#46107 closed feature request (fixed)
Scripts: Assign api-fetch nonce with corrected rest_nonce
Reported by: | aduth | Owned by: | aduth |
---|---|---|---|
Milestone: | 5.2 | Priority: | high |
Severity: | normal | Version: | 5.1 |
Component: | Script Loader | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
Previously: #45113
Related: https://github.com/WordPress/gutenberg/pull/13451
The above package change for @wordpress/api-fetch
will have the affect both that api-fetch
will not internally listen for hearbeat.tick
actions, but also that the nonce used for requests can be assignable on the created middleware.
Thus, core could use this new mechanism to assign the nonce via an inline script on heartbeat tick, using the corrected rest_nonce
property on a heartbeat response which had temporarily been patched in r43939 for the sake of api-fetch
compatibility.
The release schedule of @wordpress/api-fetch
would be such that it's expected this would need to be fixed in time for WordPress 5.2.
Attachments (3)
Change History (9)
#1
@
6 years ago
- Milestone changed from Awaiting Review to 5.2
- Version set to 5.1
@aduth Looks good to me!
It would be good to have the expected nonce behavior covered in a test, do you know if we have that already?
#2
@
6 years ago
It would be good to have the expected nonce behavior covered in a test, do you know if we have that already?
I'm not aware of any. Is there precedent for how something like this would be tested? I could imagine one which tests that wp-hooks
becomes added as a dependency of wp-api-fetch
, but the main behavior here occurs in the browser in response to the heartbeat tick. Is that something which could be done in the QUnit tests? In Gutenberg, I could maybe imagine an end-to-end test forcing wp.heartbeat.connectNow
and asserting in one way or another that the nonce used by the apiFetch
middleware gets updated. Is there some equivalent we could implement in core? Maybe it ought to just be implemented in Gutenberg? Or as part of some future end-to-end tests implemented in core?
Add missing semi-colon