Opened 7 years ago
Last modified 8 months ago
#49478 new defect (bug)
get_post_type_object has the wrong type of validator for its parameter
| Reported by: | kamilkecki | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Posts, Post Types | Version: | 5.3.2 |
| Severity: | normal | Keywords: | has-patch 2nd-opinion dev-feedback |
| Cc: | Focuses: |
Description
https://core.trac.wordpress.org/browser/tags/5.3/src/wp-includes/post.php?rev=46727#L1228
get_post_type_object expects a post type as a string as its parameter, however it checks if the parameter is scalar or not and returns null if it is not a number.
Attachments (1)
Change History (4)
#3
@
8 months ago
- Keywords dev-feedback added; needs-testing removed
Tested on before patch and with 49748.diff WordPress 7.0-alpha-61215-src.
get_post_type_object() returns an object for valid string inputs and null for all non-string values, so the issue is not reproducible functionally.
The behavior is already safe, but the validator still uses is_scalar() while the docblock specifies a string. Using is_string() would better match the documented contract and improve clarity/type safety.
Removing needs-testing and adding dev-feedback since this appears to be a minor code quality improvement and may need maintainer input.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Hi there, welcome to WordPress Trac! Thanks for the ticket.
Just adding a link to the related changeset here: [34100] / #30013.