[wp-trac] [WordPress Trac] #44723: The user ID in a `WP_User_Request` is not an integer as stated

WordPress Trac noreply at wordpress.org
Fri Aug 3 21:13:34 UTC 2018


#44723: The user ID in a `WP_User_Request` is not an integer as stated
----------------------------------------+---------------------
 Reporter:  desrosj                     |       Owner:  (none)
     Type:  defect (bug)                |      Status:  new
 Priority:  normal                      |   Milestone:  4.9.9
Component:  Privacy                     |     Version:  4.9.6
 Severity:  normal                      |  Resolution:
 Keywords:  has-patch needs-unit-tests  |     Focuses:
----------------------------------------+---------------------

Comment (by garrett-eclipse):

 Interesting enough but if you go down the rabbit hole although the codex
 states WP_Post's post_author is 'A numeric string, for compatibility
 reasons' it's default is the numeric 0 and in wp_insert_post it's
 expecting an (int) but if not provided uses the return of
 get_current_user_id which is an int.

 $post_author in WP_Post -
 https://core.trac.wordpress.org/browser/tags/4.9.8/src/wp-includes/class-
 wp-post.php#L32
 wp_insert_post Codex -
 https://developer.wordpress.org/reference/functions/wp_insert_post/
 $user_id in wp_insert_post -
 https://core.trac.wordpress.org/browser/tags/4.9.8/src/wp-
 includes/post.php#L3139
 get_current_user_id Codex -
 https://developer.wordpress.org/reference/functions/get_current_user_id/

 So it's weird it seems it's always an int down the chain so not sure why
 it's saying it's a numeric string.

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


More information about the wp-trac mailing list