Skip to content

Commit 0ca1919

Browse files
authored
Manual Updates: Make sure manual updates are applied when auto updates are disabled (#40534)
* Do not use constant for plugin updates * Add changelog entry file
1 parent af88e1a commit 0ca1919

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: other
3+
4+
API Endpoints: make sure manual plugin updates applied when auto update is disabled

projects/plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-plugins-modify-endpoint.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -383,9 +383,12 @@ protected function deactivate() {
383383
*/
384384
protected function update() {
385385
$query_args = $this->query_args();
386+
387+
$is_automatic_update = false;
386388
if ( isset( $query_args['autoupdate'] ) && $query_args['autoupdate'] || $this->scheduled_update ) {
387-
Constants::set_constant( 'JETPACK_PLUGIN_AUTOUPDATE', true );
389+
$is_automatic_update = true;
388390
}
391+
389392
if ( $this->scheduled_update ) {
390393
Constants::set_constant( 'SCHEDULED_AUTOUPDATE', true );
391394
}
@@ -416,7 +419,7 @@ protected function update() {
416419

417420
// Early return if unable to obtain auto_updater lock.
418421
// @see https://github.com/WordPress/wordpress-develop/blob/66469efa99e7978c8824e287834135aa9842e84f/src/wp-admin/includes/class-wp-automatic-updater.php#L453.
419-
if ( Constants::get_constant( 'JETPACK_PLUGIN_AUTOUPDATE' ) && ! WP_Upgrader::create_lock( 'auto_updater', $lock_release_timeout ) ) {
422+
if ( $is_automatic_update && ! WP_Upgrader::create_lock( 'auto_updater', $lock_release_timeout ) ) {
420423
return new WP_Error( 'update_fail', __( 'Updates are already in progress.', 'jetpack' ), 400 );
421424
}
422425

@@ -430,7 +433,7 @@ protected function update() {
430433
}
431434

432435
// Rely on WP_Automatic_Updater class to check if a plugin item should be updated if it is a Jetpack autoupdate request.
433-
if ( Constants::get_constant( 'JETPACK_PLUGIN_AUTOUPDATE' ) && ! ( new WP_Automatic_Updater() )->should_update( 'plugin', $update_plugins->response[ $plugin ], WP_PLUGIN_DIR ) ) {
436+
if ( $is_automatic_update && ! ( new WP_Automatic_Updater() )->should_update( 'plugin', $update_plugins->response[ $plugin ], WP_PLUGIN_DIR ) ) {
434437
continue;
435438
}
436439

@@ -473,7 +476,7 @@ protected function update() {
473476
}
474477

475478
// release auto_udpate lock.
476-
if ( Constants::get_constant( 'JETPACK_PLUGIN_AUTOUPDATE' ) ) {
479+
if ( $is_automatic_update ) {
477480
WP_Upgrader::release_lock( 'auto_updater' );
478481
}
479482

0 commit comments

Comments
 (0)