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

Commit 758fbf7

Browse files
authored
Merge pull request #30 from woocommerce/fix/27-suspend-jp-sync-during-rest-response
Add another URI for which to disable jetpack sync
2 parents 97f3d11 + 5c0c597 commit 758fbf7

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

hotfixes/wc-api-dev-jetpack-hotfixes.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,24 @@
1616
* See also https://core.trac.wordpress.org/ticket/41358#ticket
1717
* See also https://github.com/Automattic/jetpack/pull/7482
1818
*
19-
* This can be removed once we have either of the two fixes above released
19+
* This can be removed once we have either of the two fixes above released. The first
20+
* trigger string is typical of a direct request (e.g. ala Postman) and the second
21+
* trigger string is typical of a request from WordPress.com for Jetpack.
2022
*
2123
* See also https://github.com/woocommerce/woocommerce/pull/16158
24+
*
25+
* @since 0.7.0
26+
* @version 0.7.1
2227
*/
2328

2429
function wc_api_dev_jetpack_sync_sender_should_load( $sender_should_load ) {
25-
$starts_with = '/wp-json/wc/v';
26-
if ( $starts_with === substr( $_SERVER[ 'REQUEST_URI' ], 0, strlen( $starts_with ) ) ) {
27-
$sender_should_load = false;
30+
$trigger_strings = array( '/wp-json/wc/v', '/?rest_route=%2Fwc%2Fv' );
31+
32+
foreach( $trigger_strings as $trigger_string ) {
33+
if ( false !== strpos( $_SERVER[ 'REQUEST_URI' ], $trigger_string ) ) {
34+
$sender_should_load = false;
35+
break;
36+
}
2837
}
2938

3039
return $sender_should_load;

readme.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: automattic, woothemes
33
Tags: woocommerce, rest-api, api
44
Requires at least: 4.6
55
Tested up to: 4.8
6-
Stable tag: 0.7.0
6+
Stable tag: 0.7.1
77
License: GPLv2 or later
88
License URI: http://www.gnu.org/licenses/gpl-2.0.html
99

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

2626
== Changelog ==
2727

28+
= 0.7.1 =
29+
* Fix - add another URI to watch for when disabling sync during API requests
30+
2831
= 0.7.0 =
2932
* Fix - disable jetpack sync during rest api requests to avoid slow responses
3033

wc-api-dev.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: WooCommerce API Dev
44
* Plugin URI: https://woocommerce.com/
55
* Description: A feature plugin providing a bleeding edge version of the WooCommerce REST API.
6-
* Version: 0.7.0
6+
* Version: 0.7.1
77
* Author: Automattic
88
* Author URI: https://woocommerce.com
99
* Requires at least: 4.4

0 commit comments

Comments
 (0)