Skip to content

Commit c9105b3

Browse files
authored
[bulk-update] Properly handle update data inclusion during bulk-updating. (#854)
1 parent 9f7e5e6 commit c9105b3

2 files changed

Lines changed: 25 additions & 5 deletions

File tree

includes/class-fs-plugin-updater.php

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -540,9 +540,32 @@ function pre_set_site_transient_update_plugins_filter( $transient_data ) {
540540
return $transient_data;
541541
}
542542

543+
// Alias.
544+
$basename = $this->_fs->premium_plugin_basename();
545+
543546
global $wp_current_filter;
544547

545-
if ( ! empty( $wp_current_filter ) && in_array( 'upgrader_process_complete', $wp_current_filter ) ) {
548+
/**
549+
* During bulk updates, avoid re-injecting update data for the plugin itself once it has already been updated.
550+
*
551+
* If the custom package is re-added to the transient after the plugin update, WordPress may detect the package again and incorrectly report "The plugin is at the latest version" for a pending update, since the custom package version matches the currently installed version.
552+
*
553+
* Behavior differs depending on how the bulk update is triggered. Please refer to the inline comments for each flow below for details.
554+
*/
555+
if (
556+
! empty( $wp_current_filter ) && (
557+
/**
558+
* update-core.php and other upgrader pages:
559+
* The `upgrader_process_complete` action fires only once after all updates have finished. In this case, it is the current action (`$wp_current_filter[0]`), while `self::$_upgrade_basename` may contain any plugin basename.
560+
*/
561+
'upgrader_process_complete' === $wp_current_filter[0] ||
562+
/**
563+
* AJAX bulk updates (e.g., from the Plugins page):
564+
* The `upgrader_process_complete` action fires multiple times — once for each plugin after it finishes updating. In this flow, it is not the current action (`$wp_current_filter[0]`) because it is triggered from another action. Instead, we compare `self::$_upgrade_basename` with the basename of the plugin currently being updated, since the `upgrader_process_complete` action runs separately for each plugin.
565+
*/
566+
( in_array( 'upgrader_process_complete', $wp_current_filter ) && self::$_upgrade_basename === $basename )
567+
)
568+
) {
546569
return $transient_data;
547570
}
548571

@@ -566,9 +589,6 @@ function pre_set_site_transient_update_plugins_filter( $transient_data ) {
566589
}
567590
}
568591

569-
// Alias.
570-
$basename = $this->_fs->premium_plugin_basename();
571-
572592
if ( is_object( $this->_update_details ) ) {
573593
if ( isset( $transient_data->no_update ) ) {
574594
unset( $transient_data->no_update[ $basename ] );

start.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
* @var string
1717
*/
18-
$this_sdk_version = '2.13.0.5';
18+
$this_sdk_version = '2.13.0.6';
1919

2020
#region SDK Selection Logic --------------------------------------------------------------------
2121

0 commit comments

Comments
 (0)