[wp-trac] [WordPress Trac] #53177: WP_User_Query doesn't not accept fields as string except ID

WordPress Trac noreply at wordpress.org
Mon May 10 23:08:05 UTC 2021


#53177: WP_User_Query doesn't not accept fields as string except ID
--------------------------+------------------------------
 Reporter:  rilwis        |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Users         |     Version:  4.4
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:  docs
--------------------------+------------------------------
Changes (by peterwilsoncc):

 * version:  trunk => 4.4


Comment:

 Thanks for the report.

 I think it's a bug and either `WP_User_Query::fill_query_vars()` or the
 `if` statement you highlight ought to ensure the fields value is an array.
 The `if` statement would probably need some re-ordering if the value were
 forced to an array.

 In pseudo code:

 {{{#!php
 <?php
 $qv['fields'] = (array) $qv['fields'];

 if ( in_array( 'all', $qv['fields'], true ) {
   // all fields
 } elseif ( ! empty( $qv['fields'] ) {
   // Custom list of fields
 } else {
   // ID
 }
 }}}

 For now I've set the version to the introduction of
 `WP_User_Query::fill_query_vars()` but the issue may have been
 introduced/incorrectly documented earlier.

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


More information about the wp-trac mailing list