From 4c4fd4d1b2a5b178915ac5970f86faab12998fcc Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Tue, 4 Mar 2025 13:50:21 +0000 Subject: [PATCH] Upgrade/Install: Prevent an unnecessary plugin update check when the plugin update data is up to date. This ensures the `checked` property is always populated with the latest plugin data before determining whether to perform an update check. Previously this was only populated when the data was already identified as being stale, which could result in a subsequent unnecessary update check when viewing the Plugins screen. Props siliconforks, bookdude13, pbiron, francina, Cybr, snehapatil02, johnbillion Fixes #44118, #61055 Built from https://develop.svn.wordpress.org/trunk@59926 git-svn-id: http://core.svn.wordpress.org/trunk@59268 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/update.php | 17 +++++++++-------- wp-includes/version.php | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/wp-includes/update.php b/wp-includes/update.php index bf5d9b24d8..d9ee34c971 100644 --- a/wp-includes/update.php +++ b/wp-includes/update.php @@ -337,12 +337,6 @@ function wp_update_plugins( $extra_stats = array() ) { $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. @@ -371,8 +365,6 @@ function wp_update_plugins( $extra_stats = array() ) { $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; } @@ -461,6 +453,15 @@ function wp_update_plugins( $extra_stats = array() ) { 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 ) ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index a0043a8738..6b87219d60 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.8-alpha-59925'; +$wp_version = '6.8-alpha-59926'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.