-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix incorrect global post object when field is fields => 'id=>parent
for WP_Query.
#7985
base: trunk
Are you sure you want to change the base?
Fix incorrect global post object when field is fields => 'id=>parent
for WP_Query.
#7985
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. |
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
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.