-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Revisions Controller: return single revision only when it matches the parent id #5655
Revisions Controller: return single revision only when it matches the parent id #5655
Conversation
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 for following up with this fix! Looks like a good approach to me, just left a tiny comment about the value used in the error message.
src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php
Outdated
Show resolved
Hide resolved
src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php
Outdated
Show resolved
Hide resolved
src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php
Show resolved
Hide resolved
…se parent does not match the `parent` route fragment.
…t the supplied parent id. If it doesn't match, return a 404 Updated test coverage Update error message in class-wp-rest-revisions-controller.php
9f528bf
to
6fdc982
Compare
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.
Looks good! Thanks for your work on this, @ramonjd
I'll let @adamsilverstein give it a final review.
src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php
Outdated
Show resolved
Hide resolved
src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php
Outdated
Show resolved
Hide resolved
string replacement type signifier %d Co-authored-by: Daniel Bachhuber <[email protected]>
Thanks, folks. I appreciate the testing and reviews! |
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.
Nice work!
@ramonjd Has this change been tested with https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-template-revisions-controller.php controller that extends this controller? |
Good point. I can add a relevant unit test to the |
No. I was mixing up the results of See below. |
Actually, withdraw that, I should have checked The check in The results of Regardless, I've also double checked other registered post types, none of which, I'd submit, therefore, that this PR is fine as it is. Thanks for the reviews! |
src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php
Outdated
Show resolved
Hide resolved
Thanks a lot for the feedback @spacedmonkey! 🙇🏻 I'll get it done today or tomorrow. |
Adding parent id revision parent_id mismatch invalid test to the templates revisions controller tests Remove specific mention of "post" to discern between other post types, e.g., "template"
ae49d86
to
ff84ef6
Compare
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. |
…nt ID is returned in the error message.
…, e.g., "template"
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.
Excellent, thanks for all the tests!
Committed in r57222. |
… individual items.
… individual items.
This is required to sync with WordPress/wordpress-develop#5655
…59049) This is required to sync with WordPress/wordpress-develop#5655 Co-authored-by: ramonjd <[email protected]> Co-authored-by: andrewserong <[email protected]>
… individual items.
… individual items.
This patch adds a condition to
WP_REST_Revisions_Controller->get_item
that checks the revision parent id against the supplied parent id.If it doesn't match, the method returns a 404.
This is to ensure that
get_item
does not return a revision whose parent does not match theparent
route fragment.Test coverage added.
Run tests:
npm run test:php -- --filter WP_Test_REST_Revisions_Controller
Commit 1a7ff6c demonstrates that currently,
get_item()
can return the revision of different parent post of that same type.Trac ticket: https://core.trac.wordpress.org/ticket/59875
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.