[wp-trac] [WordPress Trac] #56952: cache_users() not defined when calling get_user without field parameter or using all_with_meta or all

WordPress Trac noreply at wordpress.org
Wed Nov 9 01:59:59 UTC 2022


#56952: cache_users() not defined when calling get_user without field parameter or
using all_with_meta or all
-------------------------------------------------+-------------------------
 Reporter:  carazo                               |       Owner:
                                                 |  TimothyBlynJacobs
     Type:  defect (bug)                         |      Status:  closed
 Priority:  normal                               |   Milestone:  6.1.1
Component:  Users                                |     Version:  6.1
 Severity:  major                                |  Resolution:  fixed
 Keywords:  has-patch has-testing-info commit    |     Focuses:
  fixed-major                                    |  performance
-------------------------------------------------+-------------------------
Changes (by peterwilsoncc):

 * status:  reopened => closed
 * resolution:   => fixed


Comment:

 In [changeset:"54773" 54773]:
 {{{
 #!CommitTicketReference repository="" revision="54773"
 Query: Don't attempt caching if running a WP_User_Query before
 plugins_loaded.

 In #55594 user meta caching was enabled by default when making a
 `WP_User_Query`. Previously, this was only enabled if a developer
 specifically queried for 'all_with_meta'
 fields. User meta caching is implemented using a pluggable function,
 `cache_users`. If a plugin runs a `WP_User_Query` before pluggable
 functions have been defined, this
 will now cause a fatal error.

 In this commit, a `function_exists` check is introduced to avoid calling
 `cache_users` if it's not defined. Additionally, a `_doing_it_wrong`
 notice is issued if the
 `WP_User_Query::query` method is called before the 'plugins_loaded' hook.

 Props carazo, subrataemfluence, oakesjosh, spacedmonkey, obenland,
 SergeyBiryukov, peterwilsoncc, TimothyBlynJacobs.
 Merges [54766] to the 6.1 branch.
 Fixes #56952.
 }}}

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


More information about the wp-trac mailing list