WP_User_Query::query()
- Since
- 3.1.0
- Source
wp-includes/class-wp-user-query.php:782
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
- Scaling
- Scales with input
- Instructions
- 25–153
- Plugin surface
- 2 hooks
- Called by
- 1
Reaches the database via WP_User_Query::query().
The body loops, so the work grows with how much data it finds.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 200.
Third-party callbacks on 'users_pre_query', 'found_users_query' run inside this call, and their cost is not bounded by anything here.
1 place in core call this, so the cost is paid more often than your own code shows.
What it touches
- sqldatabase query
WP_User_Query::query()this function does it - hookthird-party callbacks
apply_filters_ref_array()called directly - cacheobject cache
wp_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.
| When | Instructions | Calls it makes |
|---|---|---|
did_action() | 25–44 | did_action() |
!did_action() | 37–56 | did_action(), __(), sprintf(), _doing_it_wrong() |
did_action() && !function_exists() | 41–55 | did_action(), function_exists() |
did_action() && function_exists() | 46–60 | did_action(), function_exists(), cache_users() |
!did_action() && !function_exists() | 53–67 | did_action(), __(), sprintf(), _doing_it_wrong(), function_exists() |
!did_action() && function_exists() | 58–72 | did_action(), __(), sprintf(), _doing_it_wrong(), function_exists(), cache_users() |
did_action() && !$qv && $cache_value !== false | 66–85 | did_action(), ->generate_cache_key(), ->get_cache_last_changed() |
did_action() && $qv && $cache_value !== false | 72–91 | did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted() |
did_action() && !$qv && $cache_value === false | 73–94 | did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col() |
did_action() && !$qv && $cache_value === false | 74–95 | did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results() |
!did_action() && !$qv && $cache_value !== false | 78–97 | did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed() |
did_action() && $cache_value === false | 79–100 | did_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 === false | 80–101 | did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_results() |
did_action() && !$qv && $cache_value !== false && !function_exists() | 82–96 | did_action(), ->generate_cache_key(), ->get_cache_last_changed(), function_exists() |
did_action() && $cache_value === false | 84–105 | did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col(), wp_cache_set_salted() |
!did_action() && $qv && $cache_value !== false | 84–103 | did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted() |
did_action() && $cache_value === false | 85–106 | did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results(), wp_cache_set_salted() |
!did_action() && !$qv && $cache_value === false | 85–106 | did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col() |
!did_action() && !$qv && $cache_value === false | 86–107 | did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results() |
did_action() && !$qv && $cache_value !== false && function_exists() | 87–101 | did_action(), ->generate_cache_key(), ->get_cache_last_changed(), function_exists(), cache_users() |
did_action() && $qv && $cache_value !== false && !function_exists() | 88–102 | did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), function_exists() |
did_action() && $cache_value === false && isset($qv) | 88–107 | did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col(), apply_filters(), ->get_var() |
did_action() && !$qv && $cache_value === false && !function_exists() | 89–105 | did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col(), function_exists() |
did_action() && $cache_value === false && isset($qv) | 89–108 | did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results(), apply_filters(), ->get_var() |
did_action() && !$qv && $cache_value === false && !function_exists() | 90–106 | did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results(), function_exists() |
did_action() && $qv && $cache_value === false | 90–111 | did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_col(), wp_cache_set_salted() |
did_action() && $qv && $cache_value === false | 91–112 | did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_results(), wp_cache_set_salted() |
!did_action() && $cache_value === false | 91–112 | did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_col() |
!did_action() && $cache_value === false | 92–113 | did_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–107 | did_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–110 | did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col(), function_exists(), cache_users() |
did_action() && $cache_value === false && isset($qv) | 94–113 | did_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–108 | did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), function_exists() |
did_action() && !$qv && $cache_value === false && function_exists() | 95–111 | did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results(), function_exists(), cache_users() |
did_action() && $cache_value === false && !function_exists() | 95–111 | did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_col(), function_exists() |
did_action() && $cache_value === false && isset($qv) | 95–114 | did_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–112 | did_action(), ->generate_cache_key(), ->get_cache_last_changed(), wp_cache_get_salted(), ->get_results(), function_exists() |
!did_action() && $cache_value === false | 96–117 | did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col(), wp_cache_set_salted() |
!did_action() && $cache_value === false | 97–118 | did_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–118 | did_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–113 | did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), function_exists(), cache_users() |
did_action() && $cache_value === false && !function_exists() | 100–116 | did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col(), wp_cache_set_salted(), function_exists() |
did_action() && $cache_value === false && isset($qv) | 100–119 | did_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–116 | did_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–114 | did_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–119 | did_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–117 | did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results(), wp_cache_set_salted(), function_exists() |
did_action() && $cache_value === false && function_exists() | 101–117 | did_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–117 | did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col(), function_exists() |
!did_action() && $cache_value === false && isset($qv) | 101–120 | did_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–118 | did_action(), __(), sprintf(), _doing_it_wrong(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_results(), function_exists() |
!did_action() && $qv && $cache_value === false | 102–123 | did_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 === false | 103–124 | did_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–118 | did_action(), ->generate_cache_key(), ->get_cache_last_changed(), ->get_col(), apply_filters(), ->get_var(), function_exists() |
did_action() && $cache_value === false && function_exists() | 105–121 | did_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–119 | did_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–124 | did_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–119 | did_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–122 | did_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–122 | did_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–125 | did_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–122 | did_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–125 | did_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–123 | did_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–123 | did_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–123 | did_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–126 | did_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–124 | did_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–123 | did_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–124 | did_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–124 | did_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–127 | did_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–125 | did_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–130 | did_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–128 | did_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–128 | did_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–131 | did_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–128 | did_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–129 | did_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–129 | did_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–129 | did_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–129 | did_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–130 | did_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–130 | did_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–130 | did_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–133 | did_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–131 | did_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–136 | did_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–134 | did_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–134 | did_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–137 | did_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–135 | did_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–134 | did_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–135 | did_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–135 | did_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–135 | did_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–136 | did_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–136 | did_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–136 | did_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–139 | did_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–137 | did_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–140 | did_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–140 | did_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–141 | did_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–141 | did_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–141 | did_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–142 | did_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–142 | did_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–146 | did_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–147 | did_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–147 | did_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–148 | did_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–152 | did_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–153 | did_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:
- apply_filters( users_pre_query )filterline 820 (+38 into the body)
Filters the users array before the query takes place.
- 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
- did_action()Retrieves the number of times an action has been fired during the current request.
- _doing_it_wrong()Marks something as being incorrectly called.
- __()Retrieves the translation of $text.
- apply_filters_ref_array()Calls the callback functions that have been added to a filter hook, specifying arguments in an array.
- wp_cache_get_salted()Retrieves cached data if valid and unchanged.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- wp_cache_set_salted()Stores salted data in the cache.
- cache_users()Retrieves info for user lists to prevent multiple queries by get_userdata().
- WP_User_Query::generate_cache_key()Generate cache key.
- WP_User_Query::get_cache_last_changed()Retrieves the last changed cache timestamp for users and optionally posts.
- WP_User::__construct()Constructor.
Used by · 1
- WP_User_Query::__construct()Constructor.
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 `$query` 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.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.0.4 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.