[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 23:46:09 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 peterwilsoncc):

 I did some testing with 5.6 vs 6.0 and tested the results, it seems it's
 itended that the property be lower-case according the majority of cases.

 || Fields argument || 5.9 property name || 6.0 property name ||
 || `['id']`          || $id               || $ID               ||
 || `['Id']`          || $id               || $ID               ||
 || `['ID']`          || $ID               || $ID               ||
 || `['iD']`          || $id               || $ID               ||

 As I see it there are a few options, listed in my order of preference:

 1. maintain the inconsistency
 2. return in both upper and lower case always
 3. return in lower case always (a back compat break)

 As requesting a subset of fields return an array of `stdClass`, there
 isn't the option to use a custom getter to make the property case
 insensitive.

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


More information about the wp-trac mailing list