[wp-trac] [WordPress Trac] #44510: count_user_posts() does not check for empty $userid

WordPress Trac noreply at wordpress.org
Wed Jul 4 09:31:43 UTC 2018


#44510: count_user_posts() does not check for empty $userid
--------------------------+-----------------------------
 Reporter:  Ste_95        |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Users         |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 If `count_user_posts()` is called with a `NULL` `$userid`, it will return
 the total count of all site posts, rather than 0 or some error.

 I think this should not be expected behavior and we should bail early if
 `$userid` is `NULL`. This happens because `get_posts_by_author_sql()` then
 ignores the `$userid` arg if it is NULL.

 https://core.trac.wordpress.org/browser/tags/4.9.6/src/wp-
 includes/user.php#L347

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44510>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list