-
Notifications
You must be signed in to change notification settings - Fork 2k
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
HTTP: Pass along the api version for all request methods #12839
Conversation
Previously, we would only pass it along for GET requests. This allows POST to also use api versions other than v1.
Why does the check for GET exist at all? Can't all requests (GET/POST/ etc ) use query params? |
They can indeed. I was trying to make the smallest diff, as I wasn't sure why we were excluding query params from non-GET requests. |
I'm okay with shipping this as-is because it solves a current bug, but I'd like to ideally figure out the answer to #12839 (comment) from @dmsnell |
I'm happy to wait on it, I have this patch on the PR I'm working on. |
Looks good to me @blowery! I tested the |
@dmsnell there's one other quirk I uncovered while working on #12703; for a post, you must pass along a truthy
needs to be
to work as expected. Might want to address that when we add |
…n the `query` wpcom's `req.post` has the signature: `params, [query], body, [callback]` which means positionnal arguments will move around based on the function's arity: 4: `params, query, body, callback` 3: `params, query, body` or `params, body, callback` 2: `params, body` With that in mind, the use of `compact` in the data-layer considerably complexifies the situation, as we can hit those various arities for many combinations of arguments. This tries to simplify the process while fixing a few edge cases already encountered in a few past PRs (#12135, #12839): If you want to pass `formData` (in `params`) with an `apiVersion` (in `query`), you NEED to pass a `body`, but any truth-y body will overwrite the `formData` in the HTTP request. This disqualifies the usage of `compact` as you - sometimes - want to pass a false-y values. (PR #12135) If you want to just pass an `apiVersion` (in `query`), you need - at least - another argument to have an arity of 3, which means you need to pass an empty body (PR #12839)
Previously, we would only pass it along for GET requests. This allows POST to also use api versions other than v1.