Opened 7 months ago
Closed 7 months ago
#63802 closed defect (bug) (fixed)
Incorrect @return tag in doc comment for get_post_field()
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 6.9 | Priority: | normal |
| Severity: | minor | Version: | |
| Component: | Posts, Post Types | Keywords: | has-patch |
| Focuses: | docs | Cc: |
Description
get_post_field() either returns an empty string or the sanitised post field value via sanitize_post_field().
Although the documented return type is string, the actual return value and type depend on the requested post field. For example, get_post_field('post_parent', $post_id) returns an integer value.
To align the documentation with the actual behaviour, I suggest updating the @return tag to either mixed (as documented for sanitize_post_field()) or specifying the union of all possible return types.
Change History (3)
This ticket was mentioned in PR #9411 on WordPress/wordpress-develop by @rollybueno.
7 months ago
#1
- Keywords has-patch added
Note: See
TracTickets for help on using
tickets.
Update
get_post_field()docblock to reflect actual return types(int|string|int[])instead of always string.Trac ticket: https://core.trac.wordpress.org/ticket/63802