diff --git a/projects/packages/scheduled-updates/changelog/update-health-check-to-callbacks b/projects/packages/scheduled-updates/changelog/update-health-check-to-callbacks new file mode 100644 index 0000000000000..b471debcae085 --- /dev/null +++ b/projects/packages/scheduled-updates/changelog/update-health-check-to-callbacks @@ -0,0 +1,4 @@ +Significance: minor +Type: changed + +Scheduled Updates: move health check functions into hooks diff --git a/projects/packages/scheduled-updates/composer.json b/projects/packages/scheduled-updates/composer.json index bf97b5406bc57..22b912f1ee405 100644 --- a/projects/packages/scheduled-updates/composer.json +++ b/projects/packages/scheduled-updates/composer.json @@ -49,7 +49,7 @@ }, "autotagger": true, "branch-alias": { - "dev-trunk": "0.9.x-dev" + "dev-trunk": "0.10.x-dev" }, "textdomain": "jetpack-scheduled-updates", "version-constants": { diff --git a/projects/packages/scheduled-updates/src/class-scheduled-updates-health-paths.php b/projects/packages/scheduled-updates/src/class-scheduled-updates-health-paths.php index ae9600a2c205b..7e65946b8a32a 100644 --- a/projects/packages/scheduled-updates/src/class-scheduled-updates-health-paths.php +++ b/projects/packages/scheduled-updates/src/class-scheduled-updates-health-paths.php @@ -135,4 +135,18 @@ public static function validate( $path ) { return $ret; } + + /** + * Update the health check paths for a scheduled update hook. + * + * @param string $id The ID of the schedule. + * @param object $event The event object. + * @param \WP_REST_Request $request The request object. + * @return bool + */ + public static function updates_health_paths( $id, $event, $request ) { + $schedule = $request['schedule']; + $paths = $schedule['health_check_paths'] ?? array(); + return self::update( $id, $paths ); + } } diff --git a/projects/packages/scheduled-updates/src/class-scheduled-updates.php b/projects/packages/scheduled-updates/src/class-scheduled-updates.php index 0db366ad9b206..cb046d01d1c8f 100644 --- a/projects/packages/scheduled-updates/src/class-scheduled-updates.php +++ b/projects/packages/scheduled-updates/src/class-scheduled-updates.php @@ -20,7 +20,7 @@ class Scheduled_Updates { * * @var string */ - const PACKAGE_VERSION = '0.9.1'; + const PACKAGE_VERSION = '0.10.0-alpha'; /** * The cron event hook for the scheduled plugins update. @@ -61,6 +61,8 @@ public static function init() { add_action( 'jetpack_scheduled_update_deleted', array( __CLASS__, 'enable_autoupdates' ), 10, 2 ); add_action( 'jetpack_scheduled_update_updated', array( Scheduled_Updates_Logs::class, 'replace_logs_schedule_id' ), 10, 2 ); add_action( 'jetpack_scheduled_update_deleted', array( Scheduled_Updates_Logs::class, 'delete_logs_schedule_id' ), 10, 3 ); + add_action( 'jetpack_scheduled_update_created', array( Scheduled_Updates_Health_Paths::class, 'updates_health_paths' ), 10, 3 ); + add_action( 'jetpack_scheduled_update_deleted', array( Scheduled_Updates_Health_Paths::class, 'clear' ) ); // Update cron sync option after options update. $callback = array( __CLASS__, 'update_option_cron' ); diff --git a/projects/packages/scheduled-updates/src/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-update-schedules.php b/projects/packages/scheduled-updates/src/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-update-schedules.php index 941c41bb4afcc..6caa1aa7372db 100644 --- a/projects/packages/scheduled-updates/src/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-update-schedules.php +++ b/projects/packages/scheduled-updates/src/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-update-schedules.php @@ -267,7 +267,6 @@ public function create_item( $request ) { } $id = Scheduled_Updates::generate_schedule_id( $plugins ); - Scheduled_Updates_Health_Paths::update( $id, $schedule['health_check_paths'] ?? array() ); /** * Fires when a scheduled update is created. @@ -504,8 +503,6 @@ public function delete_item( $request ) { */ do_action( 'jetpack_scheduled_update_deleted', $request['schedule_id'], $event, $request ); - Scheduled_Updates_Health_Paths::clear( $request['schedule_id'] ); - return rest_ensure_response( true ); } diff --git a/projects/plugins/mu-wpcom-plugin/changelog/update-health-check-to-callbacks b/projects/plugins/mu-wpcom-plugin/changelog/update-health-check-to-callbacks new file mode 100644 index 0000000000000..9aa70e3ec1f75 --- /dev/null +++ b/projects/plugins/mu-wpcom-plugin/changelog/update-health-check-to-callbacks @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Updated composer.lock. + + diff --git a/projects/plugins/mu-wpcom-plugin/composer.lock b/projects/plugins/mu-wpcom-plugin/composer.lock index 20468d01ef90b..4f2e0de9edca2 100644 --- a/projects/plugins/mu-wpcom-plugin/composer.lock +++ b/projects/plugins/mu-wpcom-plugin/composer.lock @@ -978,7 +978,7 @@ "dist": { "type": "path", "url": "../../packages/scheduled-updates", - "reference": "ce33d9393f024efd66071ea0eae3758f000748cc" + "reference": "f54ff98d9b5b3ba08e1684e06d722f2ac9f899be" }, "require": { "php": ">=7.0" @@ -1001,7 +1001,7 @@ }, "autotagger": true, "branch-alias": { - "dev-trunk": "0.9.x-dev" + "dev-trunk": "0.10.x-dev" }, "textdomain": "jetpack-scheduled-updates", "version-constants": {