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

WordPress Trac noreply at wordpress.org
Wed May 4 21:25:34 UTC 2022


#53177: WP_User_Query does not accept fields as string except ID
-------------------------------------------------+-------------------------
 Reporter:  rilwis                               |       Owner:  audrasjb
     Type:  defect (bug)                         |      Status:  reopened
 Priority:  normal                               |   Milestone:  6.0
Component:  Users                                |     Version:  4.4
 Severity:  normal                               |  Resolution:
 Keywords:  has-testing-info has-dev-note has-   |     Focuses:  docs
  patch has-unit-tests needs-docs                |
-------------------------------------------------+-------------------------

Comment (by kraftbj):

 Noting a change that happens with this, I believe.

 In WordPress 5.9, `$query = new \WP_User_Query( array( 'fields'  => array(
 'id' ), 'role'    => 'administrator', ) );`

 would return a `results` value that returned `id` lowercase:

 {{{
   ["results":"WP_User_Query":private]=>
   array(1) {
     [0]=>
     object(stdClass)#2379 (1) {
       ["id"]=>
       string(1) "1"
     }
   }
 }}}

 In `trunk`, it returns the same thing with capitalized ID in the response:
 {{{
   ["results":"WP_User_Query":private]=>
   array(1) {
     [0]=>
     object(stdClass)#2470 (1) {
       ["ID"]=>
       string(1) "1"
     }
   }
 }}}

 It may have been a fluke that it returned the matching capitalization and
 on our plugin, we've corrected it, but wanted to note it.

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


More information about the wp-trac mailing list