-
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
First pass at batch controller #311
Conversation
Adding a support for if ( isset( $attributes['sanitize_callback'] ) ) {
$sanitized = call_user_func( $attributes['sanitize_callback'], $this );
if ( is_wp_error( $sanitized ) ) {
return $sanitized;
}
} |
Why sanitize? The sanitize callbacks aren’t supposed to return an error instance. |
@TimothyBJacobs How else would you approach classifying e.g. this part of the It performs validation based on:
It doesn't neatly fit into the validation callback, but it fits the sanitize callback, with the only caveat being returning an error.
Returning an error instance is supported for per-field validated callback so my thinking was that a per-request callback should also support it. My bigger problem here is that the notion of validation and sanitization in the API relates to request data, whereas with endpoints like |
Why doesn't it fit in validate? The purpose of sanitize is to transform a value, AFAICT it isn't transforming a value, but validating that it is valid when combined with other request data.
Right, but I think that would be in the |
@TimothyBJacobs here's my reasoning: Consider the following block of code: What it does is this: If That code depends on Let's try to split that block of code assuming we only have the following buckets to choose from:
Let's see how it fits each of these buckets:
There is also one additional problem. See the following code: It performs validation based on the value of resolved Now let's see what would happen with per-request
It seems cleaner overall, let me know what you think or if you have any alternative ideas - I don't insist on this specific approach, just trying to figure out what would work best here :) |
� Conflicts: � src/wp-includes/rest-api.php � src/wp-settings.php � tests/phpunit/tests/rest-api/rest-schema-setup.php
This lets us keep the APIs protected. Additionally, the namespace is removed and the route becomes /batch/v1.
This allows for a defined validation step that operates on the entire request object.
4b313d1
to
7d6e6ed
Compare
I royally screwed up this rebase. Closing this out. |
Trac ticket: https://core.trac.wordpress.org/ticket/50244
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.