This pull request addresses a critical flaw in the validate_request method where it incorrectly assumed the state of a newly instantiated WP_REST_Request object without parameters. Originally, the method attempted to validate the request method and content type using this uninitialized object, leading to a logical mistake where the validation could never properly execute due to the absence of correctly set values within the WP_REST_Request object.
Key Changes:
Removed the creation and use of an empty WP_REST_Request object for method and content type checks.
Implemented direct validation against the $_SERVER global for 'REQUEST_METHOD' and 'CONTENT_TYPE'.
Simplified the method's logic, improving readability and maintainability.
Related tickets & documents
None
Description
This pull request addresses a critical flaw in the
validate_request
method where it incorrectly assumed the state of a newly instantiatedWP_REST_Request
object without parameters. Originally, the method attempted to validate the request method and content type using this uninitialized object, leading to a logical mistake where the validation could never properly execute due to the absence of correctly set values within theWP_REST_Request
object.Key Changes:
WP_REST_Request
object for method and content type checks.$_SERVER
global for 'REQUEST_METHOD' and 'CONTENT_TYPE'.