WP_Site_Health::get_test_persistent_object_cache(): array
- Since
- 6.1.0
- Source
wp-admin/includes/class-wp-site-health.php:2560
Compatibility
- WordPress
- since 6.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.
Return value
array- The test result.
Performance profile
How much work a call to WP_Site_Health::get_test_persistent_object_cache() 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
- Trivial
- Scaling
- Constant
- Instructions
- 49–93
- Plugin surface
- 2 hooks
- Called by
- 0
Touches nothing outside its own arguments.
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 100.
Third-party callbacks on 'site_status_persistent_object_cache_url', 'site_status_persistent_object_cache_notes' run inside this call, and their cost is not bounded by anything here.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
apply_filters()called directly
Further down the call graph this can also reach query, option, cache, 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 · 4 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_Site_Health::get_test_persistent_object_cache() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
wp_using_ext_object_cache() | 49 | __(), apply_filters(), __(), __(), __(), esc_url(), __(), __(), wp_using_ext_object_cache() |
!wp_using_ext_object_cache() && !->should_suggest_persistent_object_cache() | 57 | __(), apply_filters(), __(), __(), __(), esc_url(), __(), __(), wp_using_ext_object_cache(), ->should_suggest_persistent_object_cache(), __() |
!wp_using_ext_object_cache() && ->should_suggest_persistent_object_cache() && empty($available_services) | 83 | __(), apply_filters(), __(), __(), __(), esc_url(), __(), __(), wp_using_ext_object_cache(), ->should_suggest_persistent_object_cache(), ->available_object_cache_services(), __(), apply_filters(), __(), wp_kses() |
!wp_using_ext_object_cache() && ->should_suggest_persistent_object_cache() && !empty($available_services) | 93 | __(), apply_filters(), __(), __(), __(), esc_url(), __(), __(), wp_using_ext_object_cache(), ->should_suggest_persistent_object_cache(), ->available_object_cache_services(), __(), __(), sprintf(), apply_filters(), __(), wp_kses() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 100 | 49–93 | 3 | |
| 8.5 | 100 | 49–93 | 3 | |
| 8.4 | 100 | 49–93 | 3 | 4 fewer instructions than PHP 8.3 |
| 8.3 | 104 | 49–97 | 3 | |
| 8.2 | 104 | 49–97 | 3 | |
| 8.1 | 104 | 49–97 | 3 | |
| 7.4 | 104 | 49–97 | 3 |
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_Site_Health::get_test_persistent_object_cache() runs, in this order:
- apply_filters( site_status_persistent_object_cache_url )filterline 2568 (+8 into the body)
Filters the action URL for the persistent object cache health check.
- apply_filters( site_status_persistent_object_cache_notes )filterline 2630 (+70 into the body)
Filters the second paragraph of the health check's description when suggesting the use of a persistent object cache.
Uses · 7
- apply_filters()Calls the callback functions that have been added to a filter hook.
- __()Retrieves the translation of $text.
- esc_url()Checks and cleans a URL.
- wp_using_ext_object_cache()Toggles `$_wp_using_ext_object_cache` on and off without directly touching global.
- wp_kses()Filters text content and strips out disallowed HTML.
- WP_Site_Health::should_suggest_persistent_object_cache()Determines whether to suggest using a persistent object cache.
- WP_Site_Health::available_object_cache_services()Returns a list of available persistent object cache services.
Source code
public function get_test_persistent_object_cache() { /** * Filters the action URL for the persistent object cache health check. * * @since 6.1.0 * * @param string $action_url Learn more link for persistent object cache health check. */ $action_url = apply_filters( 'site_status_persistent_object_cache_url', /* translators: Localized Support reference. */ __( 'https://developer.wordpress.org/advanced-administration/performance/optimization/#object-caching' ) ); $result = array( 'test' => 'persistent_object_cache', 'status' => 'good', 'badge' => array( 'label' => __( 'Performance' ), 'color' => 'blue', ), 'label' => __( 'A persistent object cache is being used' ), 'description' => sprintf( '<p>%s</p>', __( 'A persistent object cache makes your site’s database more efficient, resulting in faster load times because WordPress can retrieve your site’s content and settings much more quickly.' ) ), 'actions' => sprintf( '<p><a href="%s" target="_blank">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>', esc_url( $action_url ), __( 'Learn more about persistent object caching.' ), /* translators: Hidden accessibility text. */ __( '(opens in a new tab)' ) ), ); if ( wp_using_ext_object_cache() ) { return $result; } if ( ! $this->should_suggest_persistent_object_cache() ) { $result['label'] = __( 'A persistent object cache is not required' ); return $result; } $available_services = $this->available_object_cache_services(); $notes = __( 'Your hosting provider can tell you if a persistent object cache can be enabled on your site.' ); if ( ! empty( $available_services ) ) { $notes .= ' ' . sprintf( /* translators: Available object caching services. */ __( 'Your host appears to support the following object caching services: %s.' ), implode( ', ', $available_services ) ); } /** * Filters the second paragraph of the health check's description * when suggesting the use of a persistent object cache. * * Hosts may want to replace the notes to recommend their preferred object caching solution. * * Plugin authors may want to append notes (not replace) on why object caching is recommended for their plugin. * * @since 6.1.0 * * @param string $notes The notes appended to the health check description. * @param string[] $available_services The list of available persistent object cache services. */ $notes = apply_filters( 'site_status_persistent_object_cache_notes', $notes, $available_services ); $result['status'] = 'recommended'; $result['label'] = __( 'You should use a persistent object cache' ); $result['description'] .= sprintf( '<p>%s</p>', wp_kses( $notes, array( 'a' => array( 'href' => true ),Changelog
Introduced in 6.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.1.0 tag, from
src/wp-admin/includes/class-wp-site-health.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.