WP_User_Query::get_cache_last_changed( array $args ): string[]
- Since
- 6.9.0
- Source
wp-includes/class-wp-user-query.php:1071
Compatibility
- WordPress
- since 6.9.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in 3 of the 5 tracked releases, added in 6.9.0, and compiles on PHP 7.4 through 8.6-dev.
Parameters
$argsarray- Query arguments.
Return value
string[]- The last changed timestamp string for the relevant cache groups.
Performance profile
How much work a call to WP_User_Query::get_cache_last_changed() 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
- Light
- Scaling
- Constant
- Instructions
- 18–48
- Plugin surface
- None
- Called by
- 1
Only touches the object cache, via wp_cache_get_last_changed().
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 52.
Nothing here hands control to plugin code.
1 place in core call this, so the cost is paid more often than your own code shows.
What it touches
- cacheobject cache
wp_cache_get_last_changed()called directly - regexregular expression over the whole input
preg_split()called directly - hookthird-party callbacks
do_action()one call below WP_User_Query::get_cache_last_changed()
What one call costs · 36 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_User_Query::get_cache_last_changed() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!isset($args) && !$args && !$ordersby | 18–21 | wp_cache_get_last_changed() |
!isset($args) | 24–30 | wp_cache_get_last_changed(), wp_cache_get_last_changed() |
isset($args) && !$args && !$ordersby | 24–27 | wp_cache_get_last_changed(), absint() |
!empty($args) && !isset($args) && !$args && !$ordersby | 25 | wp_cache_get_last_changed(), preg_split() |
!isset($args) | 26–32 | wp_cache_get_last_changed(), wp_cache_get_last_changed(), restore_current_blog() |
!isset($args) | 27–33 | wp_cache_get_last_changed(), switch_to_blog(), wp_cache_get_last_changed() |
!isset($args) | 27–33 | wp_cache_get_last_changed(), get_current_blog_id(), wp_cache_get_last_changed() |
!isset($args) | 29–35 | wp_cache_get_last_changed(), switch_to_blog(), wp_cache_get_last_changed(), restore_current_blog() |
!isset($args) | 29–35 | wp_cache_get_last_changed(), get_current_blog_id(), wp_cache_get_last_changed(), restore_current_blog() |
isset($args) | 30–36 | wp_cache_get_last_changed(), absint(), wp_cache_get_last_changed() |
!isset($args) | 30–36 | wp_cache_get_last_changed(), get_current_blog_id(), switch_to_blog(), wp_cache_get_last_changed() |
!empty($args) && !isset($args) | 31–34 | wp_cache_get_last_changed(), preg_split(), wp_cache_get_last_changed() |
24 further outcomes, up to 48 instructions
!empty($args) && isset($args) && !$args && !$ordersby | 31 | wp_cache_get_last_changed(), preg_split(), absint() |
isset($args) | 32–38 | wp_cache_get_last_changed(), absint(), wp_cache_get_last_changed(), restore_current_blog() |
!isset($args) | 32–38 | wp_cache_get_last_changed(), get_current_blog_id(), switch_to_blog(), wp_cache_get_last_changed(), restore_current_blog() |
!empty($args) && !isset($args) | 33–36 | wp_cache_get_last_changed(), preg_split(), wp_cache_get_last_changed(), restore_current_blog() |
isset($args) | 33–39 | wp_cache_get_last_changed(), absint(), switch_to_blog(), wp_cache_get_last_changed() |
isset($args) | 33–39 | wp_cache_get_last_changed(), absint(), get_current_blog_id(), wp_cache_get_last_changed() |
!empty($args) && !isset($args) | 34–37 | wp_cache_get_last_changed(), preg_split(), switch_to_blog(), wp_cache_get_last_changed() |
!empty($args) && !isset($args) | 34–37 | wp_cache_get_last_changed(), preg_split(), get_current_blog_id(), wp_cache_get_last_changed() |
isset($args) | 35–41 | wp_cache_get_last_changed(), absint(), switch_to_blog(), wp_cache_get_last_changed(), restore_current_blog() |
isset($args) | 35–41 | wp_cache_get_last_changed(), absint(), get_current_blog_id(), wp_cache_get_last_changed(), restore_current_blog() |
!empty($args) && !isset($args) | 36–39 | wp_cache_get_last_changed(), preg_split(), switch_to_blog(), wp_cache_get_last_changed(), restore_current_blog() |
!empty($args) && !isset($args) | 36–39 | wp_cache_get_last_changed(), preg_split(), get_current_blog_id(), wp_cache_get_last_changed(), restore_current_blog() |
isset($args) | 36–42 | wp_cache_get_last_changed(), absint(), get_current_blog_id(), switch_to_blog(), wp_cache_get_last_changed() |
!empty($args) && isset($args) | 37–40 | wp_cache_get_last_changed(), preg_split(), absint(), wp_cache_get_last_changed() |
!empty($args) && !isset($args) | 37–40 | wp_cache_get_last_changed(), preg_split(), get_current_blog_id(), switch_to_blog(), wp_cache_get_last_changed() |
isset($args) | 38–44 | wp_cache_get_last_changed(), absint(), get_current_blog_id(), switch_to_blog(), wp_cache_get_last_changed(), restore_current_blog() |
!empty($args) && isset($args) | 39–42 | wp_cache_get_last_changed(), preg_split(), absint(), wp_cache_get_last_changed(), restore_current_blog() |
!empty($args) && !isset($args) | 39–42 | wp_cache_get_last_changed(), preg_split(), get_current_blog_id(), switch_to_blog(), wp_cache_get_last_changed(), restore_current_blog() |
!empty($args) && isset($args) | 40–43 | wp_cache_get_last_changed(), preg_split(), absint(), switch_to_blog(), wp_cache_get_last_changed() |
!empty($args) && isset($args) | 40–43 | wp_cache_get_last_changed(), preg_split(), absint(), get_current_blog_id(), wp_cache_get_last_changed() |
!empty($args) && isset($args) | 42–45 | wp_cache_get_last_changed(), preg_split(), absint(), switch_to_blog(), wp_cache_get_last_changed(), restore_current_blog() |
!empty($args) && isset($args) | 42–45 | wp_cache_get_last_changed(), preg_split(), absint(), get_current_blog_id(), wp_cache_get_last_changed(), restore_current_blog() |
!empty($args) && isset($args) | 43–46 | wp_cache_get_last_changed(), preg_split(), absint(), get_current_blog_id(), switch_to_blog(), wp_cache_get_last_changed() |
!empty($args) && isset($args) | 45–48 | wp_cache_get_last_changed(), preg_split(), absint(), get_current_blog_id(), switch_to_blog(), wp_cache_get_last_changed(), restore_current_blog() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 52 | 18–48 | 8 | |
| 8.5 | 52 | 18–48 | 8 | |
| 8.4 | 52 | 18–48 | 8 | 3 fewer instructions than PHP 8.3 |
| 8.3 | 55 | 21–51 | 8 | |
| 8.2 | 55 | 21–51 | 8 | |
| 8.1 | 55 | 21–51 | 8 | |
| 7.4 | 55 | 21–51 | 8 |
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.
Uses · 5
- wp_cache_get_last_changed()Gets last changed date for the specified cache group.
- absint()Converts a value to non-negative integer.
- get_current_blog_id()Retrieves the current site ID.
- switch_to_blog()Switches the current blog.
- restore_current_blog()Restores the current blog, after calling switch_to_blog().
Used by · 1
- WP_User_Query::query()Executes the query, with the current variables.
Source code
protected function get_cache_last_changed( array $args ) { $last_changed = (array) wp_cache_get_last_changed( 'users' ); if ( empty( $args['orderby'] ) ) { // Default order is by 'user_login'. $ordersby = array( 'user_login' => '' ); } elseif ( is_array( $args['orderby'] ) ) { $ordersby = $args['orderby']; } else { // 'orderby' values may be a comma- or space-separated list. $ordersby = preg_split( '/[,\s]+/', $args['orderby'] ); } $blog_id = 0; if ( isset( $args['blog_id'] ) ) { $blog_id = absint( $args['blog_id'] ); } if ( $args['has_published_posts'] || in_array( 'post_count', $ordersby, true ) ) { $switch = $blog_id && get_current_blog_id() !== $blog_id; if ( $switch ) { switch_to_blog( $blog_id ); } $last_changed[] = wp_cache_get_last_changed( 'posts' ); if ( $switch ) { restore_current_blog(); } } return $last_changed; }Changelog
Introduced in 6.9.0. Unchanged from 6.9.7 through 7.1.0.
Signature, return type and hooks compared across 3 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 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.