@@ -383,9 +383,12 @@ protected function deactivate() {
383
383
*/
384
384
protected function update () {
385
385
$ query_args = $ this ->query_args ();
386
+
387
+ $ is_automatic_update = false ;
386
388
if ( isset ( $ query_args ['autoupdate ' ] ) && $ query_args ['autoupdate ' ] || $ this ->scheduled_update ) {
387
- Constants:: set_constant ( ' JETPACK_PLUGIN_AUTOUPDATE ' , true ) ;
389
+ $ is_automatic_update = true ;
388
390
}
391
+
389
392
if ( $ this ->scheduled_update ) {
390
393
Constants::set_constant ( 'SCHEDULED_AUTOUPDATE ' , true );
391
394
}
@@ -416,7 +419,7 @@ protected function update() {
416
419
417
420
// Early return if unable to obtain auto_updater lock.
418
421
// @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 ) ) {
420
423
return new WP_Error ( 'update_fail ' , __ ( 'Updates are already in progress. ' , 'jetpack ' ), 400 );
421
424
}
422
425
@@ -430,7 +433,7 @@ protected function update() {
430
433
}
431
434
432
435
// 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 ) ) {
434
437
continue ;
435
438
}
436
439
@@ -473,7 +476,7 @@ protected function update() {
473
476
}
474
477
475
478
// release auto_udpate lock.
476
- if ( Constants:: get_constant ( ' JETPACK_PLUGIN_AUTOUPDATE ' ) ) {
479
+ if ( $ is_automatic_update ) {
477
480
WP_Upgrader::release_lock ( 'auto_updater ' );
478
481
}
479
482
0 commit comments