[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 2 22:55: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:  accepted
 Priority:  normal                      |   Milestone:  6.1.1
Component:  Users                       |     Version:  6.1
 Severity:  major                       |  Resolution:
 Keywords:  has-patch has-testing-info  |     Focuses:
----------------------------------------+--------------------------------
Changes (by TimothyBlynJacobs):

 * keywords:  has-patch => has-patch has-testing-info


Comment:

 Thanks for the patch @oakesjosh!

 The alternative would be to manually load `pluggable.php` instead of
 skipping the cache call. However, that would end up preventing any plugins
 loaded ''after'' the offending plugin from overriding any pluggable
 functions.

 While not caching these requests isn't ideal, I think it's better than
 potentially breaking `pluggable.php`. We could consider adding a
 `_doing_it_wrong` here with an indication to wait until `plugins_loaded`
 before making any queries as well.

 Cc: @peterwilsoncc, @spacedmonkey.

 I don't think this is unit testable, since `pluggable.php` will have
 already been loaded by the test bootstrap. However, to test manually,
 create a plugin with the following code.

 {{{#!php
 <?php
 /*
  * Plugin Name: Test Plugin
  */

 if ( isset( $_GET['test_query'] ) ) {
         $users = get_users();

         wp_die( sprintf( '%d users', count( $users ) ), 'Queried users',
 array( 'response' => 200 ) );
 }
 }}}

 If you visit `https://yoursite.com?test_query`, you should see the number
 of users successfully queried on a WP Die screen. Otherwise, you'll see a
 fatal error.

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


More information about the wp-trac mailing list