WP_Site_Health::get_test_update_temp_backup_writable(): array
- Since
- 6.3.0
- Source
wp-admin/includes/class-wp-site-health.php:1940
Compatibility
- WordPress
- since 6.3.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 results.
Performance profile
How much work a call to WP_Site_Health::get_test_update_temp_backup_writable() 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
- Moderate
- Scaling
- Constant
- Instructions
- 52–130
- Plugin surface
- None
- Called by
- 0
Reads stored settings via get_option(), cached per request but not free on a cold cache.
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 259.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
apply_filters()one call below WP_Site_Health::get_test_update_temp_backup_writable() - optionoption read or write
get_option()one call below WP_Site_Health::get_test_update_temp_backup_writable()
Further down the call graph this can also reach cache, serialize, query 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 · 7 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_update_temp_backup_writable() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
$credentials === false | 52–55 | __(), __(), __(), sprintf(), function_exists(), ob_start(), request_filesystem_credentials(), ob_end_clean(), __(), __() |
$credentials !== false && !WP_Filesystem() | 56–59 | __(), __(), __(), sprintf(), function_exists(), ob_start(), request_filesystem_credentials(), ob_end_clean(), WP_Filesystem(), __(), __() |
$credentials !== false && WP_Filesystem() | 66–69 | __(), __(), __(), sprintf(), function_exists(), ob_start(), request_filesystem_credentials(), ob_end_clean(), WP_Filesystem(), ->wp_content_dir(), __(), __(), sprintf() |
$credentials !== false && WP_Filesystem() | 94–107 | __(), __(), __(), sprintf(), function_exists(), ob_start(), request_filesystem_credentials(), ob_end_clean(), WP_Filesystem(), ->wp_content_dir(), ->is_dir(), ->is_writable(), ->is_dir(), ->is_writable(), ->is_dir(), ->is_writable(), ->is_dir(), ->is_writable() |
$credentials !== false && WP_Filesystem() && ->is_writable() | 97–111 | __(), __(), __(), sprintf(), function_exists(), ob_start(), request_filesystem_credentials(), ob_end_clean(), WP_Filesystem(), ->wp_content_dir(), ->is_dir(), ->is_writable(), ->is_dir(), ->is_writable(), ->is_dir(), ->is_writable(), ->is_dir(), ->is_writable(), ->is_writable() |
$credentials !== false && WP_Filesystem() | 109–124 | __(), __(), __(), sprintf(), function_exists(), ob_start(), request_filesystem_credentials(), ob_end_clean(), WP_Filesystem(), ->wp_content_dir(), ->is_dir(), ->is_writable(), ->is_dir(), ->is_writable(), ->is_dir(), ->is_writable(), ->is_dir(), ->is_writable(), __(), __(), sprintf() |
$credentials !== false && WP_Filesystem() && !->is_writable() | 116–130 | __(), __(), __(), sprintf(), function_exists(), ob_start(), request_filesystem_credentials(), ob_end_clean(), WP_Filesystem(), ->wp_content_dir(), ->is_dir(), ->is_writable(), ->is_dir(), ->is_writable(), ->is_dir(), ->is_writable(), ->is_dir(), ->is_writable(), ->is_writable(), __(), __(), sprintf() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 259 instructions, 52–130 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.
Uses · 3
- __()Retrieves the translation of $text.
- request_filesystem_credentials()Displays a form to the user to request for their FTP/SSH details in order to connect to the filesystem.
- WP_Filesystem()Initializes and connects the WordPress Filesystem Abstraction classes.
Source code
public function get_test_update_temp_backup_writable() { global $wp_filesystem; $result = array( 'label' => __( 'Plugin and theme temporary backup directory is writable' ), 'status' => 'good', 'badge' => array( 'label' => __( 'Security' ), 'color' => 'blue', ), 'description' => sprintf( /* translators: %s: wp-content/upgrade-temp-backup */ '<p>' . __( 'The %s directory used to improve the stability of plugin and theme updates is writable.' ) . '</p>', '<code>wp-content/upgrade-temp-backup</code>' ), 'actions' => '', 'test' => 'update_temp_backup_writable', ); if ( ! function_exists( 'WP_Filesystem' ) ) { require_once ABSPATH . 'wp-admin/includes/file.php'; } ob_start(); $credentials = request_filesystem_credentials( '' ); ob_end_clean(); if ( false === $credentials || ! WP_Filesystem( $credentials ) ) { $result['status'] = 'recommended'; $result['label'] = __( 'Could not access filesystem' ); $result['description'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' ); return $result; } $wp_content = $wp_filesystem->wp_content_dir(); if ( ! $wp_content ) { $result['status'] = 'critical'; $result['label'] = __( 'Unable to locate WordPress content directory' ); $result['description'] = sprintf( /* translators: %s: wp-content */ '<p>' . __( 'The %s directory cannot be located.' ) . '</p>', '<code>wp-content</code>' ); return $result; } $upgrade_dir_exists = $wp_filesystem->is_dir( "$wp_content/upgrade" ); $upgrade_dir_is_writable = $wp_filesystem->is_writable( "$wp_content/upgrade" ); $backup_dir_exists = $wp_filesystem->is_dir( "$wp_content/upgrade-temp-backup" ); $backup_dir_is_writable = $wp_filesystem->is_writable( "$wp_content/upgrade-temp-backup" ); $plugins_dir_exists = $wp_filesystem->is_dir( "$wp_content/upgrade-temp-backup/plugins" ); $plugins_dir_is_writable = $wp_filesystem->is_writable( "$wp_content/upgrade-temp-backup/plugins" ); $themes_dir_exists = $wp_filesystem->is_dir( "$wp_content/upgrade-temp-backup/themes" ); $themes_dir_is_writable = $wp_filesystem->is_writable( "$wp_content/upgrade-temp-backup/themes" ); if ( $plugins_dir_exists && ! $plugins_dir_is_writable && $themes_dir_exists && ! $themes_dir_is_writable ) { $result['status'] = 'critical'; $result['label'] = __( 'Plugin and theme temporary backup directories exist but are not writable' ); $result['description'] = sprintf( /* translators: 1: wp-content/upgrade-temp-backup/plugins, 2: wp-content/upgrade-temp-backup/themes. */ '<p>' . __( 'The %1$s and %2$s directories exist but are not writable. These directories are used to improve the stability of plugin updates. Please make sure the server has write permissions to these directories.' ) . '</p>', '<code>wp-content/upgrade-temp-backup/plugins</code>', '<code>wp-content/upgrade-temp-backup/themes</code>' ); return $result; } if ( $plugins_dir_exists && ! $plugins_dir_is_writable ) { $result['status'] = 'critical'; $result['label'] = __( 'Plugin temporary backup directory exists but is not writable' ); $result['description'] = sprintf( /* translators: %s: wp-content/upgrade-temp-backup/plugins */ '<p>' . __( 'The %s directory exists but is not writable. This directory is used to improve the stability of plugin updates. Please make sure the server has write permissions to this directory.' ) . '</p>', '<code>wp-content/upgrade-temp-backup/plugins</code>' ); return $result; }Changelog
Introduced in 6.3.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.