Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

Disable jetpack sync during REST requests #28

Merged
merged 2 commits into from
Jul 18, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions hotfixes/wc-api-dev-jetpack-hotfixes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* Jetpack compatibility hotfixes
*
* @since 0.7.0
*/

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

/**
* Disables jetpack sync during rest requests to avoid lengthly (> 5 second) response
* times during the shutdown action for things like product creation
*
* See also https://core.trac.wordpress.org/ticket/41358#ticket
* See also https://github.com/Automattic/jetpack/pull/7482
*
* This can be removed once we have either of the two fixes above released
*
* See also https://github.com/woocommerce/woocommerce/pull/16158
*/

function wc_api_dev_jetpack_sync_sender_should_load( $sender_should_load ) {
if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
$sender_should_load = false;
}

return $sender_should_load;
}

add_filter( 'jetpack_sync_sender_should_load', 'wc_api_dev_jetpack_sync_sender_should_load', 999 );
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: automattic, woothemes
Tags: woocommerce, rest-api, api
Requires at least: 4.6
Tested up to: 4.8
Stable tag: 0.6.0
Stable tag: 0.7.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -25,6 +25,9 @@ This section describes how to install the plugin and get it working.

== Changelog ==

= 0.7.0 =
* Fix - disable jetpack sync during rest api requests to avoid slow responses

= 0.6.0 =
* Fix value default return on settings endpoints
* Fix broken variation image set
Expand Down
5 changes: 4 additions & 1 deletion wc-api-dev.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: WooCommerce API Dev
* Plugin URI: https://woocommerce.com/
* Description: A feature plugin providing a bleeding edge version of the WooCommerce REST API.
* Version: 0.6.0
* Version: 0.7.0
* Author: Automattic
* Author URI: https://woocommerce.com
* Requires at least: 4.4
Expand Down Expand Up @@ -117,6 +117,9 @@ public function includes() {
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-dev-system-status-tools-controller.php' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-dev-shipping-methods-controller.php' );
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-dev-payment-gateways-controller.php' );

// Things that aren't related to a specific endpoint but to things like cross-plugin compatibility
include_once( dirname( __FILE__ ) . '/hotfixes/wc-api-dev-jetpack-hotfixes.php' );
}

/**
Expand Down