wppaste
WordPress

WP_User_Query::query()

Since
3.1.0
Source
wp-includes/class-wp-user-query.php:782
Executes the query, with the current variables.

Compatibility

WordPress
since 3.1.0
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.

Performance profile

How much work a call to WP_User_Query::query() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Heavy

Reaches the database via WP_User_Query::query().

Scaling
Scales with input

The body loops, so the work grows with how much data it finds.

Instructions
25–153

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 200.

Plugin surface
2 hooks

Third-party callbacks on 'users_pre_query', 'found_users_query' run inside this call, and their cost is not bounded by anything here.

Called by
1

1 place in core call this, so the cost is paid more often than your own code shows.

What it touches

  • sqldatabase queryWP_User_Query::query()this function does it
  • hookthird-party callbacksapply_filters_ref_array()called directly
  • cacheobject cachewp_cache_get_salted()called directly

Further down the call graph this can also reach query, option, serialize and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.

What one call costs · 114 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_User_Query::query() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
did_action()25–44did_action()
!did_action()37–56did_action(), __(), sprintf(), _doing_it_wrong()
did_action() && !function_exists()41–55did_action(), function_exists()
did_action() && function_exists()46–60did_action(), function_exists(), cache_users()
!did_action() && !function_exists()53–67did_action(), __(), sprintf(), _doing_it_wrong(), function_exists()
!did_action() && function_exists()58–72did_action(), __(), sprintf(), _doing_it_wrong(), function_exists(), cache_users()
did_action() && !$qv && $cache_value !== false66–85did_action(), ->generate_cache_key(), ->get_cache_last_changed()
did_action() && $qv && $cache_value !== false72–91did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted()
did_action() && !$qv && $cache_value === false73–94did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col()
did_action() && !$qv && $cache_value === false74–95did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results()
!did_action() && !$qv && $cache_value !== false78–97did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed()
did_action() && $cache_value === false79–100did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_col()
102 further outcomes, up to 153 instructions
did_action() && $cache_value === false80–101did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_results()
did_action() && !$qv && $cache_value !== false && !function_exists()82–96did_action(), ->generate_cache_key(), ->get_cache_last_changed(), function_exists()
did_action() && $cache_value === false84–105did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col(), wp_cache_set_salted()
!did_action() && $qv && $cache_value !== false84–103did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted()
did_action() && $cache_value === false85–106did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results(), wp_cache_set_salted()
!did_action() && !$qv && $cache_value === false85–106did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col()
!did_action() && !$qv && $cache_value === false86–107did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results()
did_action() && !$qv && $cache_value !== false && function_exists()87–101did_action(), ->generate_cache_key(), ->get_cache_last_changed(), function_exists(), cache_users()
did_action() && $qv && $cache_value !== false && !function_exists()88–102did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), function_exists()
did_action() && $cache_value === false && isset($qv)88–107did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col(), apply_filters(), ->get_var()
did_action() && !$qv && $cache_value === false && !function_exists()89–105did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col(), function_exists()
did_action() && $cache_value === false && isset($qv)89–108did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results(), apply_filters(), ->get_var()
did_action() && !$qv && $cache_value === false && !function_exists()90–106did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results(), function_exists()
did_action() && $qv && $cache_value === false90–111did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_col(), wp_cache_set_salted()
did_action() && $qv && $cache_value === false91–112did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_results(), wp_cache_set_salted()
!did_action() && $cache_value === false91–112did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_col()
!did_action() && $cache_value === false92–113did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_results()
did_action() && $qv && $cache_value !== false && function_exists()93–107did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), function_exists(), cache_users()
did_action() && !$qv && $cache_value === false && function_exists()94–110did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col(), function_exists(), cache_users()
did_action() && $cache_value === false && isset($qv)94–113did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_col(), apply_filters(), ->get_var()
!did_action() && !$qv && $cache_value !== false && !function_exists()94–108did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), function_exists()
did_action() && !$qv && $cache_value === false && function_exists()95–111did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results(), function_exists(), cache_users()
did_action() && $cache_value === false && !function_exists()95–111did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_col(), function_exists()
did_action() && $cache_value === false && isset($qv)95–114did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_results(), apply_filters(), ->get_var()
did_action() && $cache_value === false && !function_exists()96–112did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_results(), function_exists()
!did_action() && $cache_value === false96–117did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col(), wp_cache_set_salted()
!did_action() && $cache_value === false97–118did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results(), wp_cache_set_salted()
did_action() && $cache_value === false && isset($qv)99–118did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col(), apply_filters(), ->get_var(), wp_cache_set_salted()
!did_action() && !$qv && $cache_value !== false && function_exists()99–113did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), function_exists(), cache_users()
did_action() && $cache_value === false && !function_exists()100–116did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col(), wp_cache_set_salted(), function_exists()
did_action() && $cache_value === false && isset($qv)100–119did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results(), apply_filters(), ->get_var(), wp_cache_set_salted()
did_action() && $cache_value === false && function_exists()100–116did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_col(), function_exists(), cache_users()
!did_action() && $qv && $cache_value !== false && !function_exists()100–114did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), function_exists()
!did_action() && $cache_value === false && isset($qv)100–119did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col(), apply_filters(), ->get_var()
did_action() && $cache_value === false && !function_exists()101–117did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results(), wp_cache_set_salted(), function_exists()
did_action() && $cache_value === false && function_exists()101–117did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_results(), function_exists(), cache_users()
!did_action() && !$qv && $cache_value === false && !function_exists()101–117did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col(), function_exists()
!did_action() && $cache_value === false && isset($qv)101–120did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results(), apply_filters(), ->get_var()
!did_action() && !$qv && $cache_value === false && !function_exists()102–118did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results(), function_exists()
!did_action() && $qv && $cache_value === false102–123did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_col(), wp_cache_set_salted()
!did_action() && $qv && $cache_value === false103–124did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_results(), wp_cache_set_salted()
did_action() && $cache_value === false && isset($qv) && !function_exists()104–118did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col(), apply_filters(), ->get_var(), function_exists()
did_action() && $cache_value === false && function_exists()105–121did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col(), wp_cache_set_salted(), function_exists(), cache_users()
did_action() && $cache_value === false && isset($qv) && !function_exists()105–119did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results(), apply_filters(), ->get_var(), function_exists()
did_action() && $qv && $cache_value === false && isset($qv)105–124did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_col(), apply_filters(), ->get_var(), wp_cache_set_salted()
!did_action() && $qv && $cache_value !== false && function_exists()105–119did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), function_exists(), cache_users()
did_action() && $cache_value === false && function_exists()106–122did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results(), wp_cache_set_salted(), function_exists(), cache_users()
did_action() && $qv && $cache_value === false && !function_exists()106–122did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_col(), wp_cache_set_salted(), function_exists()
did_action() && $qv && $cache_value === false && isset($qv)106–125did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_results(), apply_filters(), ->get_var(), wp_cache_set_salted()
!did_action() && !$qv && $cache_value === false && function_exists()106–122did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col(), function_exists(), cache_users()
!did_action() && $cache_value === false && isset($qv)106–125did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_col(), apply_filters(), ->get_var()
did_action() && $qv && $cache_value === false && !function_exists()107–123did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_results(), wp_cache_set_salted(), function_exists()
!did_action() && !$qv && $cache_value === false && function_exists()107–123did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results(), function_exists(), cache_users()
!did_action() && $cache_value === false && !function_exists()107–123did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_col(), function_exists()
!did_action() && $cache_value === false && isset($qv)107–126did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_results(), apply_filters(), ->get_var()
!did_action() && $cache_value === false && !function_exists()108–124did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_results(), function_exists()
did_action() && $cache_value === false && isset($qv) && function_exists()109–123did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col(), apply_filters(), ->get_var(), function_exists(), cache_users()
did_action() && $cache_value === false && isset($qv) && function_exists()110–124did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results(), apply_filters(), ->get_var(), function_exists(), cache_users()
did_action() && $cache_value === false && isset($qv) && !function_exists()110–124did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_col(), apply_filters(), ->get_var(), function_exists()
did_action() && $qv && $cache_value === false && function_exists()111–127did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_col(), wp_cache_set_salted(), function_exists(), cache_users()
did_action() && $cache_value === false && isset($qv) && !function_exists()111–125did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_results(), apply_filters(), ->get_var(), function_exists()
!did_action() && $cache_value === false && isset($qv)111–130did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col(), apply_filters(), ->get_var(), wp_cache_set_salted()
did_action() && $qv && $cache_value === false && function_exists()112–128did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_results(), wp_cache_set_salted(), function_exists(), cache_users()
!did_action() && $cache_value === false && !function_exists()112–128did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col(), wp_cache_set_salted(), function_exists()
!did_action() && $cache_value === false && isset($qv)112–131did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results(), apply_filters(), ->get_var(), wp_cache_set_salted()
!did_action() && $cache_value === false && function_exists()112–128did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_col(), function_exists(), cache_users()
!did_action() && $cache_value === false && !function_exists()113–129did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results(), wp_cache_set_salted(), function_exists()
!did_action() && $cache_value === false && function_exists()113–129did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_results(), function_exists(), cache_users()
did_action() && $cache_value === false && isset($qv) && !function_exists()115–129did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col(), apply_filters(), ->get_var(), wp_cache_set_salted(), function_exists()
did_action() && $cache_value === false && isset($qv) && function_exists()115–129did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_col(), apply_filters(), ->get_var(), function_exists(), cache_users()
did_action() && $cache_value === false && isset($qv) && !function_exists()116–130did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results(), apply_filters(), ->get_var(), wp_cache_set_salted(), function_exists()
did_action() && $cache_value === false && isset($qv) && function_exists()116–130did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_results(), apply_filters(), ->get_var(), function_exists(), cache_users()
!did_action() && $cache_value === false && isset($qv) && !function_exists()116–130did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col(), apply_filters(), ->get_var(), function_exists()
!did_action() && $cache_value === false && function_exists()117–133did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col(), wp_cache_set_salted(), function_exists(), cache_users()
!did_action() && $cache_value === false && isset($qv) && !function_exists()117–131did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results(), apply_filters(), ->get_var(), function_exists()
!did_action() && $qv && $cache_value === false && isset($qv)117–136did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_col(), apply_filters(), ->get_var(), wp_cache_set_salted()
!did_action() && $cache_value === false && function_exists()118–134did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results(), wp_cache_set_salted(), function_exists(), cache_users()
!did_action() && $qv && $cache_value === false && !function_exists()118–134did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_col(), wp_cache_set_salted(), function_exists()
!did_action() && $qv && $cache_value === false && isset($qv)118–137did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_results(), apply_filters(), ->get_var(), wp_cache_set_salted()
!did_action() && $qv && $cache_value === false && !function_exists()119–135did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_results(), wp_cache_set_salted(), function_exists()
did_action() && $cache_value === false && isset($qv) && function_exists()120–134did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col(), apply_filters(), ->get_var(), wp_cache_set_salted(), function_exists(), cache_users()
did_action() && $cache_value === false && isset($qv) && function_exists()121–135did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results(), apply_filters(), ->get_var(), wp_cache_set_salted(), function_exists(), cache_users()
did_action() && $qv && $cache_value === false && isset($qv) && !function_exists()121–135did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_col(), apply_filters(), ->get_var(), wp_cache_set_salted(), function_exists()
!did_action() && $cache_value === false && isset($qv) && function_exists()121–135did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col(), apply_filters(), ->get_var(), function_exists(), cache_users()
did_action() && $qv && $cache_value === false && isset($qv) && !function_exists()122–136did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_results(), apply_filters(), ->get_var(), wp_cache_set_salted(), function_exists()
!did_action() && $cache_value === false && isset($qv) && function_exists()122–136did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results(), apply_filters(), ->get_var(), function_exists(), cache_users()
!did_action() && $cache_value === false && isset($qv) && !function_exists()122–136did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_col(), apply_filters(), ->get_var(), function_exists()
!did_action() && $qv && $cache_value === false && function_exists()123–139did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_col(), wp_cache_set_salted(), function_exists(), cache_users()
!did_action() && $cache_value === false && isset($qv) && !function_exists()123–137did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_results(), apply_filters(), ->get_var(), function_exists()
!did_action() && $qv && $cache_value === false && function_exists()124–140did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_results(), wp_cache_set_salted(), function_exists(), cache_users()
did_action() && $qv && $cache_value === false && isset($qv) && function_exists()126–140did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_col(), apply_filters(), ->get_var(), wp_cache_set_salted(), function_exists(), cache_users()
did_action() && $qv && $cache_value === false && isset($qv) && function_exists()127–141did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_results(), apply_filters(), ->get_var(), wp_cache_set_salted(), function_exists(), cache_users()
!did_action() && $cache_value === false && isset($qv) && !function_exists()127–141did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col(), apply_filters(), ->get_var(), wp_cache_set_salted(), function_exists()
!did_action() && $cache_value === false && isset($qv) && function_exists()127–141did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_col(), apply_filters(), ->get_var(), function_exists(), cache_users()
!did_action() && $cache_value === false && isset($qv) && !function_exists()128–142did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results(), apply_filters(), ->get_var(), wp_cache_set_salted(), function_exists()
!did_action() && $cache_value === false && isset($qv) && function_exists()128–142did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_results(), apply_filters(), ->get_var(), function_exists(), cache_users()
!did_action() && $cache_value === false && isset($qv) && function_exists()132–146did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col(), apply_filters(), ->get_var(), wp_cache_set_salted(), function_exists(), cache_users()
!did_action() && $cache_value === false && isset($qv) && function_exists()133–147did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results(), apply_filters(), ->get_var(), wp_cache_set_salted(), function_exists(), cache_users()
!did_action() && $qv && $cache_value === false && isset($qv) && !function_exists()133–147did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_col(), apply_filters(), ->get_var(), wp_cache_set_salted(), function_exists()
!did_action() && $qv && $cache_value === false && isset($qv) && !function_exists()134–148did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_results(), apply_filters(), ->get_var(), wp_cache_set_salted(), function_exists()
!did_action() && $qv && $cache_value === false && isset($qv) && function_exists()138–152did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_col(), apply_filters(), ->get_var(), wp_cache_set_salted(), function_exists(), cache_users()
!did_action() && $qv && $cache_value === false && isset($qv) && function_exists()139–153did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_results(), apply_filters(), ->get_var(), wp_cache_set_salted(), function_exists(), cache_users()

Across PHP versions

Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 200 instructions, 25–153 executed per call, 21 branches. The work does not change between versions.

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Hooks and filters fired · 2

2 hooks fire while WP_User_Query::query() runs, in this order:

  1. apply_filters( users_pre_query )filterline 820 (+38 into the body)

    Filters the users array before the query takes place.

  2. apply_filters( found_users_query )filterline 861 (+79 into the body)

    Filters SELECT FOUND_ROWS() query for the current WP_User_Query instance.

Uses · 11

Used by · 1

Source code

	public function query() {		global $wpdb; 		if ( ! did_action( 'plugins_loaded' ) ) {			_doing_it_wrong(				'WP_User_Query::query',				sprintf(				/* translators: %s: plugins_loaded */					__( 'User queries should not be run before the %s hook.' ),					'<code>plugins_loaded</code>'				),				'6.1.1'			);		} 		$qv =& $this->query_vars; 		// Do not cache results if more than 3 fields are requested.		if ( is_array( $qv['fields'] ) && count( $qv['fields'] ) > 3 ) {			$qv['cache_results'] = false;		} 		/**		 * Filters the users array before the query takes place.		 *		 * Return a non-null value to bypass WordPress' default user queries.		 *		 * Filtering functions that require pagination information are encouraged to set		 * the `total_users` property of the WP_User_Query object, passed to the filter		 * by reference. If WP_User_Query does not perform a database query, it will not		 * have enough information to generate these values itself.		 *		 * @since 5.1.0		 *		 * @param array|null    $results Return an array of user data to short-circuit WP's user query		 *                               or null to allow WP to run its normal queries.		 * @param WP_User_Query $query   The WP_User_Query instance (passed by reference).		 */		$this->results = apply_filters_ref_array( 'users_pre_query', array( null, &$this ) ); 		if ( null === $this->results ) {			// Beginning of the string is on a new line to prevent leading whitespace. See https://core.trac.wordpress.org/ticket/56841.			$this->request =				"SELECT {$this->query_fields}				 {$this->query_from}				 {$this->query_where}				 {$this->query_orderby}				 {$this->query_limit}";			$cache_value   = false;			$cache_key     = $this->generate_cache_key( $qv, $this->request );			$cache_group   = 'user-queries';			$last_changed  = $this->get_cache_last_changed( $qv ); 			if ( $qv['cache_results'] ) {				$cache_value = wp_cache_get_salted( $cache_key, $cache_group, $last_changed );			}			if ( false !== $cache_value ) {				$this->results     = $cache_value['user_data'];				$this->total_users = $cache_value['total_users'];			} else { 				if ( is_array( $qv['fields'] ) ) {					$this->results = $wpdb->get_results( $this->request );				} else {					$this->results = $wpdb->get_col( $this->request );				} 				if ( isset( $qv['count_total'] ) && $qv['count_total'] ) {					/**					 * Filters SELECT FOUND_ROWS() query for the current WP_User_Query instance.					 *					 * @since 3.2.0					 * @since 5.1.0 Added the `$this` parameter.					 *					 * @global wpdb $wpdb WordPress database abstraction object.					 *					 * @param string        $sql   The SELECT FOUND_ROWS() query for the current WP_User_Query.					 * @param WP_User_Query $query The current WP_User_Query instance.					 */					$found_users_query = apply_filters( 'found_users_query', 'SELECT FOUND_ROWS()', $this );

Changelog

Introduced in 3.1.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.9.7 tag, from src/wp-includes/class-wp-user-query.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.