fix(rest): skip middleware for method-mismatched permission checks#40
Merged
Merged
Conversation
rest_send_allow_header invokes EVERY method's permission callback on the matched route — including verbs that are not being dispatched. 4.3.2 isolated outcomes per controller but still ran each sibling method's middleware once against a request shaped for a different verb, firing validations with null params (foreach warnings, explode deprecations, and WHERE-clause queries with unbound placeholders showing up as WordPress database errors under WP_DEBUG). A controller whose method doesn't match the actual request can never dispatch, so its middleware outcome is irrelevant: advertise the method and let a real request of that verb run its own chain. Bumps version to 4.3.3.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #39: the Allow-header pass still ran sibling-method middleware once per controller against a wrong-shaped request, producing null-param warnings and unbound-placeholder DB errors under WP_DEBUG (caught by Siren's fresh-install smoke walk). A controller whose method doesn't match the dispatching request can never run, so its permission check now returns true without executing the chain. New regression test; 68 tests green.