[wp-trac] [WordPress Trac] #49478: get_post_type_object has the wrong type of validator for its parameter

WordPress Trac noreply at wordpress.org
Sun Feb 1 05:41:10 UTC 2026


#49478: get_post_type_object has the wrong type of validator for its parameter
------------------------------------------------+--------------------------
 Reporter:  kamilkecki                          |       Owner:  (none)
     Type:  defect (bug)                        |      Status:  new
 Priority:  normal                              |   Milestone:  Awaiting
                                                |  Review
Component:  Posts, Post Types                   |     Version:  5.3.2
 Severity:  normal                              |  Resolution:
 Keywords:  has-patch 2nd-opinion dev-feedback  |     Focuses:
------------------------------------------------+--------------------------
Changes (by huzaifaalmesbah):

 * keywords:  has-patch needs-testing 2nd-opinion => has-patch 2nd-opinion
     dev-feedback


Comment:

 Tested on before patch and with [attachment:"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.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/49478#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list