This repository has been archived by the owner on Oct 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from woocommerce/fix/27-suspend-jp-sync-during…
…-rest-response Disable jetpack sync during REST requests
- Loading branch information
Showing
3 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?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 ) { | ||
$starts_with = '/wp-json/wc/v'; | ||
if ( $starts_with === substr( $_SERVER[ 'REQUEST_URI' ], 0, strlen( $starts_with ) ) ) { | ||
$sender_should_load = false; | ||
} | ||
|
||
return $sender_should_load; | ||
} | ||
|
||
add_filter( 'jetpack_sync_sender_should_load', 'wc_api_dev_jetpack_sync_sender_should_load', 999 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters