Override Jetpack connection data endpoint when Jetpack is not installed (#38987)

* Override /jetpack/v4/connection/data to return 404 to fix conflict with Android app flow

* Add changelog

* Override only for the mobile devices
This commit is contained in:
Moon 2023-06-28 12:51:09 -07:00 committed by GitHub
parent b11b17c17c
commit 55280aea96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: fix
Override /jetpack/v4/connection/data to return 404 to fix conflict with Android app flow

View File

@ -11,6 +11,7 @@ defined( 'ABSPATH' ) || exit;
use ActionScheduler;
use Automattic\Jetpack\Connection\Manager;
use Automattic\Jetpack\Constants;
use Automattic\WooCommerce\Admin\PluginsHelper;
use Automattic\WooCommerce\Admin\PluginsInstallLoggers\AsynPluginsInstallLogger;
use WC_REST_Data_Controller;
@ -124,6 +125,29 @@ class OnboardingPlugins extends WC_REST_Data_Controller {
),
)
);
/*
* This is a temporary solution to override /jetpack/v4/connection/data endpoint
* registered by Jetpack Connection when Jetpack is not installed.
*
* For more details, see https://github.com/woocommerce/woocommerce/issues/38979
*/
if ( Constants::get_constant( 'JETPACK__VERSION' ) === null && wp_is_mobile() ) {
register_rest_route(
'jetpack/v4',
'/connection/data',
array(
array(
'methods' => 'GET',
'permission_callback' => '__return_true',
'callback' => function() {
return new WP_REST_Response( null, 404 );
},
),
),
true
);
}
}
/**