Fix incorrect global post object when field is fields => 'id=>parent for WP_Query.#7985
Fix incorrect global post object when field is fields => 'id=>parent for WP_Query.#7985Juzar10 wants to merge 9 commits intoWordPress:trunkfrom
fields => 'id=>parent for WP_Query.#7985Conversation
|
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. |
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. |
joemcgill
left a comment
There was a problem hiding this comment.
Rather than returning a possible int value when the current post isn't a WP_Post object, would it be better to hydrate a WP_Post object from the ID and return that instead?
|
@joemcgill, I agree with you, that would be more consistent. I have updated the logic to return |
peterwilsoncc
left a comment
There was a problem hiding this comment.
I've added a suggestion inline to expand the tests to include calls to ::next_post and to make sure requesting only the IDs returns the expected data.
Let me know what you think.
Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>
peterwilsoncc
left a comment
There was a problem hiding this comment.
Thanks @Juzar10, this change looks good to me.
I took the liberty of merging trunk in to your branch as some significant changes were committed to WP_Query in the last 24 hours so I wanted to make sure there weren't any conflicts.
|
thanks, @peterwilsoncc. |
joemcgill
left a comment
There was a problem hiding this comment.
Works for me. Thanks for the updates!
|
@joemcgill just to make sure, have you read the trac info, before approving these changes? |
|
@SirLouen thanks for the ping. I approved the PR before the ongoing conversation the Trac ticket and am happy to wait for you and @peterwilsoncc to refine the approach. |
|
This was the basis for the follow up PR #8418 which ended up being merged, thank you! |
The next_post function assumes a WP_Post object, which isn't always the case. When a standard object with ID and parent is provided, setup_postdata creates an empty WP_Post object with just the ID.
This PR resolves the issue by passing only the post ID from next_post when the object is not a WP_Post.
Trac ticket: https://core.trac.wordpress.org/ticket/56992
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.