get_core_checksums( string $version, string $locale ): array<string,
- Since
- 3.7.0
- Source
wp-admin/includes/update.php:131
Compatibility
- WordPress
- since 3.7.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.
Parameters
$versionstring- Version string to query.
$localestring- Locale to query.
Return value
array<string,- string>|false An array of checksums on success, false on failure.
Performance profile
How much work a call to get_core_checksums() 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
- Expensive
- Scaling
- Constant
- Instructions
- 36–101
- Plugin surface
- None
- Called by
- 3
Reaches an outbound HTTP request via wp_remote_get().
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 105.
Nothing here hands control to plugin code.
3 places in core call this, so the cost is paid more often than your own code shows.
What it touches
- httpoutbound HTTP request
wp_remote_get()called directly - serializeserialisation
json_decode()called directly - hookthird-party callbacks
apply_filters()one call below get_core_checksums()
Further down the call graph this can also reach query, option, cache 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 · 18 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost get_core_checksums() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
is_wp_error() | 36–37 | compact(), http_build_query(), wp_http_supports(), wp_doing_cron(), wp_remote_get(), is_wp_error() |
| always | 40–41 | compact(), http_build_query(), wp_http_supports(), wp_doing_cron(), wp_remote_get(), is_wp_error(), is_wp_error() |
!is_wp_error() | 41–42 | compact(), http_build_query(), wp_http_supports(), wp_doing_cron(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_response_code() |
is_wp_error() | 41–42 | compact(), http_build_query(), wp_http_supports(), set_url_scheme(), wp_doing_cron(), wp_remote_get(), is_wp_error() |
!is_wp_error() | 45–46 | compact(), http_build_query(), wp_http_supports(), wp_doing_cron(), wp_remote_get(), is_wp_error(), is_wp_error(), wp_remote_retrieve_response_code() |
| always | 45–46 | compact(), http_build_query(), wp_http_supports(), set_url_scheme(), wp_doing_cron(), wp_remote_get(), is_wp_error(), is_wp_error() |
!is_wp_error() | 46–47 | compact(), http_build_query(), wp_http_supports(), set_url_scheme(), wp_doing_cron(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_response_code() |
!is_wp_error() | 50–51 | compact(), http_build_query(), wp_http_supports(), set_url_scheme(), wp_doing_cron(), wp_remote_get(), is_wp_error(), is_wp_error(), wp_remote_retrieve_response_code() |
!is_wp_error() | 53–60 | compact(), http_build_query(), wp_http_supports(), wp_doing_cron(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_response_code(), wp_remote_retrieve_body(), json_decode() |
!is_wp_error() | 57–64 | compact(), http_build_query(), wp_http_supports(), wp_doing_cron(), wp_remote_get(), is_wp_error(), is_wp_error(), wp_remote_retrieve_response_code(), wp_remote_retrieve_body(), json_decode() |
!is_wp_error() | 58–65 | compact(), http_build_query(), wp_http_supports(), set_url_scheme(), wp_doing_cron(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_response_code(), wp_remote_retrieve_body(), json_decode() |
!is_wp_error() | 62–69 | compact(), http_build_query(), wp_http_supports(), set_url_scheme(), wp_doing_cron(), wp_remote_get(), is_wp_error(), is_wp_error(), wp_remote_retrieve_response_code(), wp_remote_retrieve_body(), json_decode() |
6 further outcomes, up to 101 instructions
is_wp_error() | 70–73 | compact(), http_build_query(), wp_http_supports(), wp_doing_cron(), wp_remote_get(), is_wp_error(), __(), __(), sprintf(), __(), headers_sent(), wp_trigger_error(), wp_remote_get(), is_wp_error() |
| always | 75–78 | compact(), http_build_query(), wp_http_supports(), wp_doing_cron(), wp_remote_get(), is_wp_error(), __(), __(), sprintf(), __(), headers_sent(), wp_trigger_error(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_response_code() |
is_wp_error() | 75–78 | compact(), http_build_query(), wp_http_supports(), set_url_scheme(), wp_doing_cron(), wp_remote_get(), is_wp_error(), __(), __(), sprintf(), __(), headers_sent(), wp_trigger_error(), wp_remote_get(), is_wp_error() |
| always | 80–83 | compact(), http_build_query(), wp_http_supports(), set_url_scheme(), wp_doing_cron(), wp_remote_get(), is_wp_error(), __(), __(), sprintf(), __(), headers_sent(), wp_trigger_error(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_response_code() |
| always | 87–96 | compact(), http_build_query(), wp_http_supports(), wp_doing_cron(), wp_remote_get(), is_wp_error(), __(), __(), sprintf(), __(), headers_sent(), wp_trigger_error(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_response_code(), wp_remote_retrieve_body(), json_decode() |
| always | 92–101 | compact(), http_build_query(), wp_http_supports(), set_url_scheme(), wp_doing_cron(), wp_remote_get(), is_wp_error(), __(), __(), sprintf(), __(), headers_sent(), wp_trigger_error(), wp_remote_get(), is_wp_error(), wp_remote_retrieve_response_code(), wp_remote_retrieve_body(), json_decode() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 105 | 36–101 | 11 | |
| 8.5 | 105 | 36–101 | 11 | |
| 8.4 | 105 | 36–101 | 11 | 2 fewer instructions than PHP 8.3 |
| 8.3 | 107 | 36–103 | 11 | |
| 8.2 | 107 | 36–103 | 11 | |
| 8.1 | 107 | 36–103 | 11 | |
| 7.4 | 107 | 36–103 | 11 |
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 · 9
- wp_http_supports()Determines if there is an HTTP Transport that can process this request.
- set_url_scheme()Sets the scheme for a URL.
- wp_doing_cron()Determines whether the current request is a WordPress cron request.
- wp_remote_get()Performs an HTTP request using the GET method and returns its response.
- is_wp_error()Checks whether the given variable is a WordPress Error.
- wp_trigger_error()Generates a user-level error/warning/notice/deprecation message.
- __()Retrieves the translation of $text.
- wp_remote_retrieve_response_code()Retrieves only the response code from the raw response.
- wp_remote_retrieve_body()Retrieves only the body from the raw response.
Used by · 3
- Core_Upgrader::check_files()Compares the disk file checksums against the expected checksums.
- WP_Site_Health_Auto_Updates::test_all_files_writable()Checks if core files are writable by the web user/group.
- update_core()Upgrades the core of WordPress.
Source code
function get_core_checksums( $version, $locale ) { $http_url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( compact( 'version', 'locale' ), '', '&' ); $url = $http_url; $ssl = wp_http_supports( array( 'ssl' ) ); if ( $ssl ) { $url = set_url_scheme( $url, 'https' ); } $options = array( 'timeout' => wp_doing_cron() ? 30 : 3, ); $response = wp_remote_get( $url, $options ); if ( $ssl && is_wp_error( $response ) ) { wp_trigger_error( __FUNCTION__, sprintf( /* translators: %s: Support forums URL. */ __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ), __( 'https://wordpress.org/support/forums/' ) ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE ); $response = wp_remote_get( $http_url, $options ); } if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) { return false; } $body = trim( wp_remote_retrieve_body( $response ) ); $body = json_decode( $body, true ); if ( ! is_array( $body ) || ! isset( $body['checksums'] ) || ! is_array( $body['checksums'] ) ) { return false; } return $body['checksums'];}Changelog
Introduced in 3.7.0. One change between 6.7.7 and 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
array|false to array<string,.verified against sourceAbout this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-admin/includes/update.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.