diff -r 7b1b88e27a20 -r 48c4eec2b7e6 wp/wp-admin/includes/update.php --- a/wp/wp-admin/includes/update.php Thu Sep 29 08:06:27 2022 +0200 +++ b/wp/wp-admin/includes/update.php Fri Sep 05 18:40:08 2025 +0200 @@ -15,12 +15,15 @@ */ function get_preferred_from_update_core() { $updates = get_core_updates(); + if ( ! is_array( $updates ) ) { return false; } + if ( empty( $updates ) ) { return (object) array( 'response' => 'latest' ); } + return $updates[0]; } @@ -34,13 +37,14 @@ * @return array|false Array of the update objects on success, false on failure. */ function get_core_updates( $options = array() ) { - $options = array_merge( + $options = array_merge( array( 'available' => true, 'dismissed' => false, ), $options ); + $dismissed = get_site_option( 'dismissed_update_core' ); if ( ! is_array( $dismissed ) ) { @@ -55,6 +59,7 @@ $updates = $from_api->updates; $result = array(); + foreach ( $updates as $update ) { if ( 'autoupdate' === $update->response ) { continue; @@ -72,6 +77,7 @@ } } } + return $result; } @@ -86,6 +92,7 @@ */ function find_core_auto_update() { $updates = get_site_transient( 'update_core' ); + if ( ! $updates || empty( $updates->updates ) ) { return false; } @@ -93,7 +100,8 @@ require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; $auto_update = false; - $upgrader = new WP_Automatic_Updater; + $upgrader = new WP_Automatic_Updater(); + foreach ( $updates->updates as $update ) { if ( 'autoupdate' !== $update->response ) { continue; @@ -107,6 +115,7 @@ $auto_update = $update; } } + return $auto_update; } @@ -124,6 +133,7 @@ $url = $http_url; $ssl = wp_http_supports( array( 'ssl' ) ); + if ( $ssl ) { $url = set_url_scheme( $url, 'https' ); } @@ -133,8 +143,10 @@ ); $response = wp_remote_get( $url, $options ); + if ( $ssl && is_wp_error( $response ) ) { - trigger_error( + 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 support forums.' ), @@ -142,10 +154,11 @@ ) . ' ' . __( '(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 ) ) { + if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) { return false; } @@ -170,6 +183,7 @@ function dismiss_core_update( $update ) { $dismissed = get_site_option( 'dismissed_update_core' ); $dismissed[ $update->current . '|' . $update->locale ] = true; + return update_site_option( 'dismissed_update_core', $dismissed ); } @@ -191,6 +205,7 @@ } unset( $dismissed[ $key ] ); + return update_site_option( 'dismissed_update_core', $dismissed ); } @@ -211,15 +226,19 @@ } $updates = $from_api->updates; + foreach ( $updates as $update ) { - if ( $update->current == $version && $update->locale == $locale ) { + if ( $update->current === $version && $update->locale === $locale ) { return $update; } } + return false; } /** + * Returns core update footer message. + * * @since 2.3.0 * * @param string $msg @@ -232,8 +251,9 @@ } $cur = get_preferred_from_update_core(); + if ( ! is_object( $cur ) ) { - $cur = new stdClass; + $cur = new stdClass(); } if ( ! isset( $cur->current ) ) { @@ -275,6 +295,8 @@ } /** + * Returns core update notification message. + * * @since 2.3.0 * * @global string $pagenow The filename of the current screen. @@ -299,7 +321,7 @@ $version_url = sprintf( /* translators: %s: WordPress version. */ - esc_url( __( 'https://wordpress.org/support/wordpress-version/version-%s/' ) ), + esc_url( __( 'https://wordpress.org/documentation/wordpress-version/version-%s/' ) ), sanitize_title( $cur->current ) ); @@ -321,7 +343,14 @@ ); } - echo "
{{{ data.message }}}