Skip to content

Commit cd97d65

Browse files
authored
Merge pull request #534 from ProgressPlanner/filip/v17/fix-update-transients
Fix "Perform all updates" task was incorrectly marked as completed
2 parents db6ffcb + c2dc048 commit cd97d65

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
= 1.7.0 =
2+
3+
Bugs we fixed:
4+
5+
* Fix issue where "Perform all updates" task was incorrectly marked as completed.
6+
7+
18
= 1.6.1 =
29

310
Bugs we fixed:

classes/class-suggested-tasks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct() {
4545
$this->tasks_manager = new Tasks_Manager();
4646

4747
if ( \is_admin() ) {
48-
\add_action( 'init', [ $this, 'init' ], 100 ); // Wait for the post types to be initialized.
48+
\add_action( 'admin_init', [ $this, 'init' ], 20 ); // Wait for the post types to be initialized and transients to be set.
4949

5050
// Check GET parameter and maybe set task as pending.
5151
\add_action( 'init', [ $this, 'maybe_complete_task' ] );

classes/suggested-tasks/providers/class-core-update.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,19 @@ public function should_add_task() {
124124
if ( ! \function_exists( 'get_core_updates' ) ) {
125125
require_once ABSPATH . 'wp-admin/includes/update.php'; // @phpstan-ignore requireOnce.fileNotFound
126126
}
127+
128+
// For wp_get_update_data() to return correct data it needs to be called after the 'admin_init' action (with priority 10).
127129
return 0 < \wp_get_update_data()['counts']['total'];
128130
}
131+
132+
/**
133+
* Check if the task is completed.
134+
*
135+
* @param string $task_id The task ID.
136+
*
137+
* @return bool
138+
*/
139+
public function is_task_completed( $task_id = '' ) {
140+
return \wp_doing_ajax() ? false : ! $this->should_add_task();
141+
}
129142
}

0 commit comments

Comments
 (0)