Add type checking for query vars in WP_Query::get_queried_object()#10792
Add type checking for query vars in WP_Query::get_queried_object()#10792westonruter wants to merge 3 commits intoWordPress:trunkfrom
WP_Query::get_queried_object()#10792Conversation
…tring.patch Co-authored-by: leedxw <leedxw@git.wordpress.org>
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. |
| * @return bool | ||
| */ | ||
| private function is_non_empty_string( $value ): bool { | ||
| return is_string( $value ) && '' !== $value; |
There was a problem hiding this comment.
Shell we check '' !== $value first?
There was a problem hiding this comment.
Just to validate the value first, the current implementation is defensive and quick, but do we expect to receive any numeric values here?
There was a problem hiding this comment.
Possibly. But I don't understand either way how changing the order of the conditions would be better or worse.
There was a problem hiding this comment.
To me, it seems like narrowing the scope to a string first and then checking to see if it looks like a certain string makes more sense.
There was a problem hiding this comment.
Thanks for the details. Make sense.
Trac ticket: https://core.trac.wordpress.org/ticket/64507
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.