From 324f05aa7a1b3af0a7e1717e014184c2cb194ff0 Mon Sep 17 00:00:00 2001 From: Francesco Bigiarini Date: Thu, 16 May 2024 12:34:30 +0200 Subject: [PATCH] Remove plugins check on WPCOM environment (#37416) * Remove plugins check on WPCOM environment * changelog --- .../scheduled-updates/changelog/fix-wpcom-installed-plugins | 4 ++++ .../class-wpcom-rest-api-v2-endpoint-update-schedules.php | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 projects/packages/scheduled-updates/changelog/fix-wpcom-installed-plugins diff --git a/projects/packages/scheduled-updates/changelog/fix-wpcom-installed-plugins b/projects/packages/scheduled-updates/changelog/fix-wpcom-installed-plugins new file mode 100644 index 0000000000000..4b0e43cb137f0 --- /dev/null +++ b/projects/packages/scheduled-updates/changelog/fix-wpcom-installed-plugins @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Remove plugins check on WPCOM environment 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 1dd482e203974..b78edf63ffe75 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 @@ -399,7 +399,9 @@ public function validate_plugins_param( $plugins, $request, $param ) { return $result; } - $installed_plugins = array_filter( $plugins, array( $this, 'is_plugin_installed' ) ); + // We don't need to check if plugins are installed if we're on WPCOM. + $installed_plugins = defined( 'IS_WPCOM' ) && IS_WPCOM ? $plugins : array_filter( $plugins, array( $this, 'is_plugin_installed' ) ); + if ( empty( $installed_plugins ) ) { add_filter( 'rest_request_after_callbacks', array( $this, 'transform_error_response' ) );