wp_check_php_mysql_versions()
- Since
- 3.0.0
- Source
wp-includes/load.php:153
Description
Dies if requirements are not met.
Compatibility
- WordPress
- since 3.0.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_check_php_mysql_versions() 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
- 19–93
- 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 95.
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_check_php_mysql_versions()
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 · 6 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_check_php_mysql_versions() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!version_compare() && function_exists() | 19 | version_compare(), function_exists() |
!version_compare() && !function_exists() && file_exists() | 24 | version_compare(), function_exists(), file_exists() |
version_compare() && function_exists() | 40 | version_compare(), wp_get_server_protocol(), header(), header(), printf(), exit(), function_exists() |
version_compare() && !function_exists() && file_exists() | 45 | version_compare(), wp_get_server_protocol(), header(), header(), printf(), exit(), function_exists(), file_exists() |
!version_compare() && !function_exists() && !file_exists() | 72 | version_compare(), function_exists(), file_exists(), wp_load_translations_early(), __(), __(), sprintf(), __(), __(), sprintf(), __(), wp_die(), exit() |
version_compare() && !function_exists() && !file_exists() | 93 | version_compare(), wp_get_server_protocol(), header(), header(), printf(), exit(), function_exists(), file_exists(), wp_load_translations_early(), __(), __(), sprintf(), __(), __(), sprintf(), __(), wp_die(), exit() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 95 | 19–93 | 4 | |
| 8.5 | 95 | 19–93 | 4 | |
| 8.4 | 95 | 19–93 | 4 | 1 more instruction than PHP 8.3 |
| 8.3 | 94 | 19–69 | 4 | |
| 8.2 | 94 | 19–69 | 4 | |
| 8.1 | 94 | 19–69 | 4 | 2 fewer instructions than PHP 7.4 |
| 7.4 | 96 | 20–70 | 4 |
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
- wp_get_server_protocol()Returns the HTTP protocol sent by the server.
- wp_load_translations_early()Attempts an early load of translations.
- __()Retrieves the translation of $text.
- wp_die()Kills WordPress execution and displays HTML page with an error message.
Source code
function wp_check_php_mysql_versions() { global $required_php_version, $wp_version; $php_version = PHP_VERSION; if ( version_compare( $required_php_version, $php_version, '>' ) ) { $protocol = wp_get_server_protocol(); header( sprintf( '%s 500 Internal Server Error', $protocol ), true, 500 ); header( 'Content-Type: text/html; charset=utf-8' ); printf( 'Your server is running PHP version %1$s but WordPress %2$s requires at least %3$s.', $php_version, $wp_version, $required_php_version ); exit( 1 ); } // This runs before default constants are defined, so we can't assume WP_CONTENT_DIR is set yet. $wp_content_dir = defined( 'WP_CONTENT_DIR' ) ? WP_CONTENT_DIR : ABSPATH . 'wp-content'; if ( ! function_exists( 'mysqli_connect' ) && ! file_exists( $wp_content_dir . '/db.php' ) ) { require_once ABSPATH . WPINC . '/functions.php'; wp_load_translations_early(); $message = '<p>' . __( 'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.' ) . "</p>\n"; $message .= '<p>' . sprintf( /* translators: %s: mysqli. */ __( 'Please check that the %s PHP extension is installed and enabled.' ), '<code>mysqli</code>' ) . "</p>\n"; $message .= '<p>' . sprintf( /* translators: %s: Support forums URL. */ __( 'If you are unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href="%s">WordPress support forums</a>.' ), __( 'https://wordpress.org/support/forums/' ) ) . "</p>\n"; $args = array( 'exit' => false, 'code' => 'mysql_not_found', ); wp_die( $message, __( 'Requirements Not Met' ), $args ); exit( 1 ); }}Changelog
Introduced in 3.0.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.7.7 tag, from
src/wp-includes/load.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.