[wp-trac] [WordPress Trac] #43502: `WP_REST_Posts_Controller::prepare_item_for_response()` doesn't reset postdata after calling setup_postdata()
WordPress Trac
noreply at wordpress.org
Wed Aug 29 03:53:05 UTC 2018
#43502: `WP_REST_Posts_Controller::prepare_item_for_response()` doesn't reset
postdata after calling setup_postdata()
-------------------------------------------------+-------------------------
Reporter: gerbenvandijk | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Future
| Release
Component: REST API | Version: 4.9.4
Severity: normal | Resolution:
Keywords: needs-patch needs-unit-tests good- | Focuses: rest-api
first-bug |
-------------------------------------------------+-------------------------
Changes (by rachelbaker):
* keywords: needs-patch needs-unit-tests => needs-patch needs-unit-tests
good-first-bug
Comment:
We did used to set the $post global back to the previous post in v1, but I
missed this when adding the setup_postdata() function back in v2. Setting
the global was needed for filters like `the_content` however I should have
been kind enough to restore the global when done. Be kind, rewind!
This is worth a patch and a unit test.
Some links for historical reference:
WP REST API v1 where the $post global was restored: https://github.com/WP-
API/WP-API/blob/master/lib/class-wp-json-posts.php#L687
Bug Introduced in this PR: https://github.com/WP-API/WP-API/pull/753
Responding to this issue: https://github.com/WP-API/WP-API/issues/738
--
Ticket URL: <https://core.trac.wordpress.org/ticket/43502#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list