WP_Site_Health::get_test_sql_server(): array
- Since
- 5.2.0
- Source
wp-admin/includes/class-wp-site-health.php:1204
Compatibility
- WordPress
- since 5.2.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_sql_server() 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
- Constant
- Instructions
- 53–132
- Plugin surface
- None
- Called by
- 0
Reads or writes the filesystem via file_exists().
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 135.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- filesystemfilesystem access
file_exists()called directly - hookthird-party callbacks
apply_filters()one call below WP_Site_Health::get_test_sql_server()
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 · 16 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_sql_server() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!file_exists() | 53 | __(), __(), __(), __(), esc_url(), __(), __(), file_exists() |
!file_exists() | 55 | ->prepare_sql_data(), __(), __(), __(), __(), esc_url(), __(), __(), file_exists() |
file_exists() | 73–74 | __(), __(), __(), __(), esc_url(), __(), __(), file_exists(), __(), sprintf(), wp_kses() |
file_exists() | 75–76 | ->prepare_sql_data(), __(), __(), __(), __(), esc_url(), __(), __(), file_exists(), __(), sprintf(), wp_kses() |
!file_exists() | 77–78 | __(), __(), __(), __(), esc_url(), __(), __(), file_exists(), __(), __(), sprintf() |
!file_exists() | 79–80 | ->prepare_sql_data(), __(), __(), __(), __(), esc_url(), __(), __(), file_exists(), __(), __(), sprintf() |
!file_exists() | 83–84 | __(), __(), __(), __(), esc_url(), __(), __(), file_exists(), __(), __(), __(), sprintf() |
!file_exists() | 85–86 | ->prepare_sql_data(), __(), __(), __(), __(), esc_url(), __(), __(), file_exists(), __(), __(), __(), sprintf() |
file_exists() | 97–99 | __(), __(), __(), __(), esc_url(), __(), __(), file_exists(), __(), __(), sprintf(), __(), sprintf(), wp_kses() |
file_exists() | 99–101 | ->prepare_sql_data(), __(), __(), __(), __(), esc_url(), __(), __(), file_exists(), __(), __(), sprintf(), __(), sprintf(), wp_kses() |
file_exists() | 103–105 | __(), __(), __(), __(), esc_url(), __(), __(), file_exists(), __(), __(), __(), sprintf(), __(), sprintf(), wp_kses() |
file_exists() | 105–107 | ->prepare_sql_data(), __(), __(), __(), __(), esc_url(), __(), __(), file_exists(), __(), __(), __(), sprintf(), __(), sprintf(), wp_kses() |
4 further outcomes, up to 132 instructions
!file_exists() | 107–109 | __(), __(), __(), __(), esc_url(), __(), __(), file_exists(), __(), __(), sprintf(), __(), __(), __(), sprintf() |
!file_exists() | 109–111 | ->prepare_sql_data(), __(), __(), __(), __(), esc_url(), __(), __(), file_exists(), __(), __(), sprintf(), __(), __(), __(), sprintf() |
file_exists() | 127–130 | __(), __(), __(), __(), esc_url(), __(), __(), file_exists(), __(), __(), sprintf(), __(), __(), __(), sprintf(), __(), sprintf(), wp_kses() |
file_exists() | 129–132 | ->prepare_sql_data(), __(), __(), __(), __(), esc_url(), __(), __(), file_exists(), __(), __(), sprintf(), __(), __(), __(), sprintf(), __(), sprintf(), wp_kses() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 135 | 53–132 | 7 | |
| 8.5 | 135 | 53–132 | 7 | |
| 8.4 | 135 | 53–132 | 7 | 3 fewer instructions than PHP 8.3 |
| 8.3 | 138 | 53–135 | 7 | |
| 8.2 | 138 | 53–135 | 7 | |
| 8.1 | 138 | 53–135 | 7 | |
| 7.4 | 138 | 53–135 | 7 |
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 · 4
- __()Retrieves the translation of $text.
- esc_url()Checks and cleans a URL.
- wp_kses()Filters text content and strips out disallowed HTML.
- WP_Site_Health::prepare_sql_data()Runs the SQL version checks.
Source code
public function get_test_sql_server() { if ( ! $this->mysql_server_version ) { $this->prepare_sql_data(); } $result = array( 'label' => __( 'SQL server is up to date' ), 'status' => 'good', 'badge' => array( 'label' => __( 'Performance' ), 'color' => 'blue', ), 'description' => sprintf( '<p>%s</p>', __( 'The SQL server is a required piece of software for the database WordPress uses to store all your site’s content and settings.' ) ), '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>', /* translators: Localized version of WordPress requirements if one exists. */ esc_url( __( 'https://wordpress.org/about/requirements/' ) ), __( 'Learn more about what WordPress requires to run.' ), /* translators: Hidden accessibility text. */ __( '(opens in a new tab)' ) ), 'test' => 'sql_server', ); $db_dropin = file_exists( WP_CONTENT_DIR . '/db.php' ); if ( ! $this->is_recommended_mysql_version ) { $result['status'] = 'recommended'; $result['label'] = __( 'Outdated SQL server' ); $result['description'] .= sprintf( '<p>%s</p>', sprintf( /* translators: 1: The database engine in use (MySQL or MariaDB). 2: Database server recommended version number. */ __( 'For optimal performance and security reasons, you should consider running %1$s version %2$s or higher. Contact your web hosting company to correct this.' ), ( $this->is_mariadb ? 'MariaDB' : 'MySQL' ), $this->mysql_recommended_version ) ); } if ( ! $this->is_acceptable_mysql_version ) { $result['status'] = 'critical'; $result['label'] = __( 'Severely outdated SQL server' ); $result['badge']['label'] = __( 'Security' ); $result['description'] .= sprintf( '<p>%s</p>', sprintf( /* translators: 1: The database engine in use (MySQL or MariaDB). 2: Database server minimum version number. */ __( 'WordPress requires %1$s version %2$s or higher. Contact your web hosting company to correct this.' ), ( $this->is_mariadb ? 'MariaDB' : 'MySQL' ), $this->mysql_required_version ) ); } if ( $db_dropin ) { $result['description'] .= sprintf( '<p>%s</p>', wp_kses( sprintf( /* translators: 1: The name of the drop-in. 2: The name of the database engine. */ __( 'You are using a %1$s drop-in which might mean that a %2$s database is not being used.' ), '<code>wp-content/db.php</code>', ( $this->is_mariadb ? 'MariaDB' : 'MySQL' ) ), array( 'code' => true, ) ) ); } return $result;Changelog
Introduced in 5.2.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 6.8.8 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.