ty( $current_lock_value ) ) { // Check if time has passed to overwrite the lock - min 5s? if ( is_numeric( $current_lock_value ) && ( ( $current_microtime - $current_lock_value ) < self::DEDICATED_SYNC_REQUEST_LOCK_TIMEOUT ) ) { // Still in previous lock, quit return false; } // If the value is not numeric (float/current time), we want to just overwrite it and continue. } // Update. We don't want it to autoload, as we want to fetch it right before the checks. \Jetpack_Options::update_raw_option( self::DEDICATED_SYNC_REQUEST_LOCK_OPTION_NAME, $current_microtime, false ); // Give some time for the update to happen usleep( wp_rand( 1000, 3000 ) ); $updated_value = \Jetpack_Options::get_raw_option( self::DEDICATED_SYNC_REQUEST_LOCK_OPTION_NAME, null ); if ( $updated_value === $current_microtime ) { return $current_microtime; } return false; } /** * Attempt to release the request lock. * * @param string $lock_id The request lock that's currently being held. * * @return bool|WP_Error */ public static function try_release_lock_spawn_request( $lock_id = '' ) { // Try to get the lock_id from the current request if it's not supplied. if ( empty( $lock_id ) ) { $lock_id = self::get_request_lock_id_from_request(); } // If it's still not a valid lock_id, throw an error and let the lock process figure it out. if ( empty( $lock_id ) || ! is_numeric( $lock_id ) ) { return new WP_Error( 'dedicated_request_lock_invalid', 'Invalid lock_id supplied for unlock' ); } if ( wp_using_ext_object_cache() ) { if ( (string) $lock_id === wp_cache_get( self::DEDICATED_SYNC_REQUEST_LOCK_OPTION_NAME, 'jetpack', true ) ) { wp_cache_delete( self::DEDICATED_SYNC_REQUEST_LOCK_OPTION_NAME, 'jetpack' ); } } // If this is the flow that has the lock, let's release it so we can spawn other requests afterwards $current_lock_value = \Jetpack_Options::get_raw_option( self::DEDICATED_SYNC_REQUEST_LOCK_OPTION_NAME, null ); if ( (string) $lock_id === $current_lock_value ) { \Jetpack_Options::delete_raw_option( self::DEDICATED_SYNC_REQUEST_LOCK_OPTION_NAME ); return true; } return false; } /** * Try to get the request lock id from the current request. * * @return array|string|string[]|null */ public static function get_request_lock_id_from_request() { // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( ! isset( $_GET[ self::DEDICATED_SYNC_REQUEST_LOCK_QUERY_PARAM_NAME ] ) || ! is_numeric( $_GET[ self::DEDICATED_SYNC_REQUEST_LOCK_QUERY_PARAM_NAME ] ) ) { return null; } // phpcs:ignore WordPress.Security.NonceVerification.Recommended,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized return wp_unslash( $_GET[ self::DEDICATED_SYNC_REQUEST_LOCK_QUERY_PARAM_NAME ] ); } /** * Test Sync spawning functionality by making a request to the * Sync spawning endpoint and storing the result (status code) in a transient. * * @since $$next_version$$ * * @return bool True if we got a successful response, false otherwise. */ public static function can_spawn_dedicated_sync_request() { $dedicated_sync_check_transient = self::DEDICATED_SYNC_CHECK_TRANSIENT; $dedicated_sync_response_body = get_transient( $dedicated_sync_check_transient ); if ( false === $dedicated_sync_response_body ) { $url = rest_url( 'jetpack/v4/sync/spawn-sync' ); $url = add_query_arg( 'time', time(), $url ); // Enforce Cache busting. $args = array( 'cookies' => $_COOKIE, 'timeout' => 30, /** This filter is documented in wp-includes/class-wp-http-streams.php */ 'sslverify' => apply_filters( 'https_local_ssl_verify', false ), ); $response = wp_remote_get( $url, $args ); $dedicated_sync_response_code = wp_remote_retrieve_response_code( $response ); $dedicated_sync_response_body = trim( wp_remote_retrieve_body( $response ) ); /** * Limit the size of the body that we save in the transient to avoid cases where an error * occurs and a whole generated HTML page is returned. We don't need to store the whole thing. * * The regexp check is done to make sure we can detect the string even if the body returns some additional * output, like some caching plugins do when they try to pad the request. */ $regexp = '!' . preg_quote( self::DEDICATED_SYNC_VALIDATION_STRING, '!' ) . '!uis'; if ( preg_match( $regexp, $dedicated_sync_response_body ) ) { $saved_response_body = self::DEDICATED_SYNC_VALIDATION_STRING; } else { $saved_response_body = time(); } set_transient( $dedicated_sync_check_transient, $saved_response_body, HOUR_IN_SECONDS ); // Send a bit more information to WordPress.com to help debugging issues. if ( $saved_response_body !== self::DEDICATED_SYNC_VALIDATION_STRING ) { $data = array( 'timestamp' => microtime( true ), 'response_code' => $dedicated_sync_response_code, 'response_body' => $dedicated_sync_response_body, // Send the flow type that was attempted. 'sync_flow_type' => 'dedicated', ); $sender = Sender::get_instance(); $sender->send_action( 'jetpack_sync_flow_error_enable', $data ); } } return self::DEDICATED_SYNC_VALIDATION_STRING === $dedicated_sync_response_body; } /** * Disable dedicated sync and set a transient to prevent re-enabling it for some time. * * @return void */ public static function on_dedicated_sync_lag_not_sending_threshold_reached() { set_transient( self::DEDICATED_SYNC_TEMPORARY_DISABLE_FLAG, true, 6 * HOUR_IN_SECONDS ); Settings::update_settings( array( 'dedicated_sync_enabled' => 0, ) ); // Inform that we had to temporarily disable Dedicated Sync $data = array( 'timestamp' => microtime( true ), // Send the flow type that was attempted. 'sync_flow_type' => 'dedicated', ); $sender = Sender::get_instance(); $sender->send_action( 'jetpack_sync_flow_error_temp_disable', $data ); } /** * Disable or enable Dedicated Sync sender based on the header value returned from WordPress.com * * @param string $dedicated_sync_header The Dedicated Sync header value - `on` or `off`. * * @return bool Whether Dedicated Sync is going to be enabled or not. */ public static function maybe_change_dedicated_sync_status_from_wpcom_header( $dedicated_sync_header ) { $dedicated_sync_enabled = 'on' === $dedicated_sync_header ? 1 : 0; // Prevent enabling of Dedicated sync via header flag if we're in an autoheal timeout. if ( $dedicated_sync_enabled ) { $check_transient = get_transient( self::DEDICATED_SYNC_TEMPORARY_DISABLE_FLAG ); if ( $check_transient ) { // Something happened and Dedicated Sync should not be automatically re-enabled. return false; } } Settings::update_settings( array( 'dedicated_sync_enabled' => $dedicated_sync_enabled, ) ); return Settings::is_dedicated_sync_enabled(); } }
Fatal error: Uncaught Error: Class 'Automattic\Jetpack\Sync\Dedicated_Sender' not found in /home/healths/public_html/wp-content/plugins/jetpack-social/jetpack_vendor/automattic/jetpack-sync/src/class-actions.php:109 Stack trace: #0 /home/healths/public_html/wp-content/plugins/jetpack-social/jetpack_vendor/automattic/jetpack-sync/src/class-main.php(89): Automattic\Jetpack\Sync\Actions::init() #1 /home/healths/public_html/wp-includes/class-wp-hook.php(324): Automattic\Jetpack\Sync\Main::on_plugins_loaded_late() #2 /home/healths/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #3 /home/healths/public_html/wp-includes/plugin.php(517): WP_Hook->do_action() #4 /home/healths/public_html/wp-settings.php(550): do_action() #5 /home/healths/public_html/wp-config.php(99): require_once('/home/healths/p...') #6 /home/healths/public_html/wp-load.php(50): require_once('/home/healths/p...') #7 /home/healths/public_html/wp-blog-header.php(13): require_once('/home/healths/p...') #8 /home/healths/public_html/index.php in /home/healths/public_html/wp-content/plugins/jetpack-social/jetpack_vendor/automattic/jetpack-sync/src/class-actions.php on line 109