summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2018-06-08 10:09:24 -0400
committerAnthony G. Basile <blueness@gentoo.org>2018-06-08 10:09:24 -0400
commita6b006c0f1ef757f23375f7906193370337d8bd7 (patch)
tree4467c6423b2c54e6ef8c3e79241a833fb17833a5 /plugins/jetpack/sync/class.jetpack-sync-sender.php
parentUpdate akismet 4.0.7 (diff)
downloadblogs-gentoo-a6b006c0f1ef757f23375f7906193370337d8bd7.tar.gz
blogs-gentoo-a6b006c0f1ef757f23375f7906193370337d8bd7.tar.bz2
blogs-gentoo-a6b006c0f1ef757f23375f7906193370337d8bd7.zip
Update jetpack 6.2
Diffstat (limited to 'plugins/jetpack/sync/class.jetpack-sync-sender.php')
-rw-r--r--plugins/jetpack/sync/class.jetpack-sync-sender.php48
1 files changed, 31 insertions, 17 deletions
diff --git a/plugins/jetpack/sync/class.jetpack-sync-sender.php b/plugins/jetpack/sync/class.jetpack-sync-sender.php
index 47ed3f0b..4a5b678e 100644
--- a/plugins/jetpack/sync/class.jetpack-sync-sender.php
+++ b/plugins/jetpack/sync/class.jetpack-sync-sender.php
@@ -3,6 +3,7 @@
require_once dirname( __FILE__ ) . '/class.jetpack-sync-queue.php';
require_once dirname( __FILE__ ) . '/class.jetpack-sync-defaults.php';
require_once dirname( __FILE__ ) . '/class.jetpack-sync-json-deflate-array-codec.php';
+require_once dirname( __FILE__ ) . '/class.jetpack-sync-simple-codec.php';
require_once dirname( __FILE__ ) . '/class.jetpack-sync-modules.php';
require_once dirname( __FILE__ ) . '/class.jetpack-sync-settings.php';
@@ -216,22 +217,26 @@ class Jetpack_Sync_Sender {
$checkout_duration = microtime( true ) - $checkout_start_time;
list( $items_to_send, $skipped_items_ids, $items, $preprocess_duration ) = $this->get_items_to_send( $buffer, true );
-
- /**
- * Fires when data is ready to send to the server.
- * Return false or WP_Error to abort the sync (e.g. if there's an error)
- * The items will be automatically re-sent later
- *
- * @since 4.2.0
- *
- * @param array $data The action buffer
- * @param string $codec The codec name used to encode the data
- * @param double $time The current time
- * @param string $queue The queue used to send ('sync' or 'full_sync')
- */
- Jetpack_Sync_Settings::set_is_sending( true );
- $processed_item_ids = apply_filters( 'jetpack_sync_send_data', $items_to_send, $this->codec->name(), microtime( true ), $queue->id, $checkout_duration, $preprocess_duration );
- Jetpack_Sync_Settings::set_is_sending( false );
+ if ( ! empty( $items_to_send ) ) {
+ /**
+ * Fires when data is ready to send to the server.
+ * Return false or WP_Error to abort the sync (e.g. if there's an error)
+ * The items will be automatically re-sent later
+ *
+ * @since 4.2.0
+ *
+ * @param array $data The action buffer
+ * @param string $codec The codec name used to encode the data
+ * @param double $time The current time
+ * @param string $queue The queue used to send ('sync' or 'full_sync')
+ */
+ Jetpack_Sync_Settings::set_is_sending( true );
+ $processed_item_ids = apply_filters( 'jetpack_sync_send_data', $items_to_send, $this->codec->name(), microtime( true ), $queue->id, $checkout_duration, $preprocess_duration );
+ Jetpack_Sync_Settings::set_is_sending( false );
+ } else {
+ $processed_item_ids = $skipped_items_ids;
+ $skipped_items_ids = array();
+ }
if ( ! $processed_item_ids || is_wp_error( $processed_item_ids ) ) {
$checked_in_item_ids = $queue->checkin( $buffer );
@@ -286,6 +291,13 @@ class Jetpack_Sync_Sender {
function get_codec() {
return $this->codec;
}
+ function set_codec() {
+ if ( function_exists( 'gzinflate' ) ) {
+ $this->codec = new Jetpack_Sync_JSON_Deflate_Array_Codec();
+ } else {
+ $this->codec = new Jetpack_Sync_Simple_Codec();
+ }
+ }
function send_checksum() {
require_once 'class.jetpack-sync-wp-replicastore.php';
@@ -346,10 +358,12 @@ class Jetpack_Sync_Sender {
$this->max_dequeue_time = $seconds;
}
+
+
function set_defaults() {
$this->sync_queue = new Jetpack_Sync_Queue( 'sync' );
$this->full_sync_queue = new Jetpack_Sync_Queue( 'full_sync' );
- $this->codec = new Jetpack_Sync_JSON_Deflate_Array_Codec();
+ $this->set_codec();
// saved settings
Jetpack_Sync_Settings::set_importing( null );