diff -r 48c4eec2b7e6 -r 8c2e4d02f4ef wp/wp-includes/update.php --- a/wp/wp-includes/update.php Fri Sep 05 18:40:08 2025 +0200 +++ b/wp/wp-includes/update.php Fri Sep 05 18:52:52 2025 +0200 @@ -6,10 +6,15 @@ * @since 2.3.0 */ +// Don't load directly. +if ( ! defined( 'ABSPATH' ) ) { + die( '-1' ); +} + /** * Checks WordPress version against the newest version. * - * The WordPress version, PHP version, and locale is sent. + * The WordPress version, PHP version, and locale is sent to api.wordpress.org. * * Checks against the WordPress server at api.wordpress.org. Will only check * if WordPress isn't installing. @@ -31,22 +36,20 @@ return; } - // Include an unmodified $wp_version. - require ABSPATH . WPINC . '/version.php'; $php_version = PHP_VERSION; $current = get_site_transient( 'update_core' ); $translations = wp_get_installed_translations( 'core' ); // Invalidate the transient when $wp_version changes. - if ( is_object( $current ) && $wp_version !== $current->version_checked ) { + if ( is_object( $current ) && wp_get_wp_version() !== $current->version_checked ) { $current = false; } if ( ! is_object( $current ) ) { $current = new stdClass(); $current->updates = array(); - $current->version_checked = $wp_version; + $current->version_checked = wp_get_wp_version(); } if ( ! empty( $extra_stats ) ) { @@ -95,7 +98,7 @@ $extensions = get_loaded_extensions(); sort( $extensions, SORT_STRING | SORT_FLAG_CASE ); $query = array( - 'version' => $wp_version, + 'version' => wp_get_wp_version(), 'php' => $php_version, 'locale' => $locale, 'mysql' => $mysql_version, @@ -117,24 +120,28 @@ // Filter to supported values. $gd_info = array_filter( $gd_info ); - // Add data for GD WebP and AVIF support. + // Add data for GD WebP, AVIF, HEIC and JPEG XL support. $query['image_support']['gd'] = array_keys( array_filter( array( 'webp' => isset( $gd_info['WebP Support'] ), 'avif' => isset( $gd_info['AVIF Support'] ), + 'heic' => isset( $gd_info['HEIC Support'] ), + 'jxl' => isset( $gd_info['JXL Support'] ), ) ) ); } if ( class_exists( 'Imagick' ) ) { - // Add data for Imagick WebP and AVIF support. + // Add data for Imagick WebP, AVIF, HEIC and JPEG XL support. $query['image_support']['imagick'] = array_keys( array_filter( array( 'webp' => ! empty( Imagick::queryFormats( 'WEBP' ) ), 'avif' => ! empty( Imagick::queryFormats( 'AVIF' ) ), + 'heic' => ! empty( Imagick::queryFormats( 'HEIC' ) ), + 'jxl' => ! empty( Imagick::queryFormats( 'JXL' ) ), ) ) ); @@ -147,6 +154,7 @@ * Please exercise extreme caution. * * @since 4.9.0 + * @since 6.1.0 Added `$extensions`, `$platform_flags`, and `$image_support` to the `$query` parameter. * * @param array $query { * Version check query arguments. @@ -160,6 +168,9 @@ * @type int $users Number of users on this WordPress installation. * @type int $multisite_enabled Whether this WordPress installation uses Multisite. * @type int $initial_db_version Database version of WordPress at time of installation. + * @type array $extensions List of PHP extensions and their versions. + * @type array $platform_flags List containing the operating system name and bit support. + * @type array $image_support List of image formats supported by GD and Imagick. * } */ $query = apply_filters( 'core_version_check_query_args', $query ); @@ -191,7 +202,7 @@ $options = array( 'timeout' => $doing_cron ? 30 : 3, - 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ), + 'user-agent' => 'WordPress/' . wp_get_wp_version() . '; ' . home_url( '/' ), 'headers' => array( 'wp_install' => $wp_install, 'wp_blog' => home_url( '/' ), @@ -266,7 +277,7 @@ $updates = new stdClass(); $updates->updates = $offers; $updates->last_checked = time(); - $updates->version_checked = $wp_version; + $updates->version_checked = wp_get_wp_version(); if ( isset( $body['translations'] ) ) { $updates->translations = $body['translations']; @@ -299,7 +310,7 @@ * * Despite its name this function does not actually perform any updates, it only checks for available updates. * - * A list of all plugins installed is sent to WP, along with the site locale. + * A list of all plugins installed is sent to api.wordpress.org, along with the site locale. * * Checks against the WordPress server at api.wordpress.org. Will only check * if WordPress isn't installing. @@ -315,9 +326,6 @@ return; } - // Include an unmodified $wp_version. - require ABSPATH . WPINC . '/version.php'; - // If running blog-side, bail unless we've not checked in the last 12 hours. if ( ! function_exists( 'get_plugins' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; @@ -333,12 +341,6 @@ $current = new stdClass(); } - $updates = new stdClass(); - $updates->last_checked = time(); - $updates->response = array(); - $updates->translations = array(); - $updates->no_update = array(); - $doing_cron = wp_doing_cron(); // Check for update on a different schedule, depending on the page. @@ -367,8 +369,6 @@ $plugin_changed = false; foreach ( $plugins as $file => $p ) { - $updates->checked[ $file ] = $p['Version']; - if ( ! isset( $current->checked[ $file ] ) || (string) $current->checked[ $file ] !== (string) $p['Version'] ) { $plugin_changed = true; } @@ -423,7 +423,7 @@ 'locale' => wp_json_encode( $locales ), 'all' => wp_json_encode( true ), ), - 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ), + 'user-agent' => 'WordPress/' . wp_get_wp_version() . '; ' . home_url( '/' ), ); if ( $extra_stats ) { @@ -457,6 +457,15 @@ return; } + $updates = new stdClass(); + $updates->last_checked = time(); + $updates->response = array(); + $updates->translations = array(); + $updates->no_update = array(); + foreach ( $plugins as $file => $p ) { + $updates->checked[ $file ] = $p['Version']; + } + $response = json_decode( wp_remote_retrieve_body( $raw_response ), true ); if ( $response && is_array( $response ) ) { @@ -484,19 +493,19 @@ * @param array|false $update { * The plugin update data with the latest details. Default false. * - * @type string $id Optional. ID of the plugin for update purposes, should be a URI - * specified in the `Update URI` header field. - * @type string $slug Slug of the plugin. - * @type string $version The version of the plugin. - * @type string $url The URL for details of the plugin. - * @type string $package Optional. The update ZIP for the plugin. - * @type string $tested Optional. The version of WordPress the plugin is tested against. - * @type string $requires_php Optional. The version of PHP which the plugin requires. - * @type bool $autoupdate Optional. Whether the plugin should automatically update. - * @type array $icons Optional. Array of plugin icons. - * @type array $banners Optional. Array of plugin banners. - * @type array $banners_rtl Optional. Array of plugin RTL banners. - * @type array $translations { + * @type string $id Optional. ID of the plugin for update purposes, should be a URI + * specified in the `Update URI` header field. + * @type string $slug Slug of the plugin. + * @type string $version The version of the plugin. + * @type string $url The URL for details of the plugin. + * @type string $package Optional. The update ZIP for the plugin. + * @type string $tested Optional. The version of WordPress the plugin is tested against. + * @type string $requires_php Optional. The version of PHP which the plugin requires. + * @type bool $autoupdate Optional. Whether the plugin should automatically update. + * @type string[] $icons Optional. Array of plugin icons. + * @type string[] $banners Optional. Array of plugin banners. + * @type string[] $banners_rtl Optional. Array of plugin RTL banners. + * @type array $translations { * Optional. List of translation updates for the plugin. * * @type string $language The language the translation update is for. @@ -574,7 +583,7 @@ * * Despite its name this function does not actually perform any updates, it only checks for available updates. * - * A list of all themes installed is sent to WP, along with the site locale. + * A list of all themes installed is sent to api.wordpress.org, along with the site locale. * * Checks against the WordPress server at api.wordpress.org. Will only check * if WordPress isn't installing. @@ -590,9 +599,6 @@ return; } - // Include an unmodified $wp_version. - require ABSPATH . WPINC . '/version.php'; - $installed_themes = wp_get_themes(); $translations = wp_get_installed_translations( 'themes' ); @@ -705,7 +711,7 @@ 'translations' => wp_json_encode( $translations ), 'locale' => wp_json_encode( $locales ), ), - 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ), + 'user-agent' => 'WordPress/' . wp_get_wp_version() . '; ' . home_url( '/' ), ); if ( $extra_stats ) { @@ -890,7 +896,12 @@ * * @since 3.3.0 * - * @return array + * @return array { + * Fetched update data. + * + * @type int[] $counts An array of counts for available plugin, theme, and WordPress updates. + * @type string $update_title Titles of available updates. + * } */ function wp_get_update_data() { $counts = array( @@ -973,7 +984,7 @@ * @param array $update_data { * Fetched update data. * - * @type array $counts An array of counts for available plugin, theme, and WordPress updates. + * @type int[] $counts An array of counts for available plugin, theme, and WordPress updates. * @type string $update_title Titles of available updates. * } * @param array $titles An array of update counts and UI strings for available updates. @@ -985,18 +996,13 @@ * Determines whether core should be updated. * * @since 2.8.0 - * - * @global string $wp_version The WordPress version string. */ function _maybe_update_core() { - // Include an unmodified $wp_version. - require ABSPATH . WPINC . '/version.php'; - $current = get_site_transient( 'update_core' ); if ( isset( $current->last_checked, $current->version_checked ) && 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) - && $current->version_checked === $wp_version + && wp_get_wp_version() === $current->version_checked ) { return; } @@ -1110,14 +1116,12 @@ * @access private * * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass. - * - * @return void|WP_Error Void on success, or a WP_Error object on failure. */ function _wp_delete_all_temp_backups() { global $wp_filesystem; if ( ! function_exists( 'WP_Filesystem' ) ) { - require_once ABSPATH . '/wp-admin/includes/file.php'; + require_once ABSPATH . 'wp-admin/includes/file.php'; } ob_start(); @@ -1125,15 +1129,17 @@ ob_end_clean(); if ( false === $credentials || ! WP_Filesystem( $credentials ) ) { - return new WP_Error( 'fs_unavailable', __( 'Could not access filesystem.' ) ); + wp_trigger_error( __FUNCTION__, __( 'Could not access filesystem.' ) ); + return; } if ( ! $wp_filesystem->wp_content_dir() ) { - return new WP_Error( - 'fs_no_content_dir', + wp_trigger_error( + __FUNCTION__, /* translators: %s: Directory name. */ sprintf( __( 'Unable to locate WordPress content directory (%s).' ), 'wp-content' ) ); + return; } $temp_backup_dir = $wp_filesystem->wp_content_dir() . 'upgrade-temp-backup/';