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0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / includes / class-wc-background-emailer.php
woocommerce / includes Last commit date
abstracts 4 weeks ago admin 1 week ago blocks 10 months ago cli 7 months ago customizer 3 months ago data-stores 3 weeks ago emails 1 week ago export 1 year ago gateways 2 months ago import 2 months ago integrations 4 weeks ago interfaces 3 months ago legacy 3 months ago libraries 1 year ago log-handlers 1 year ago payment-tokens 5 years ago product-usage 1 year ago queue 3 months ago react-admin 3 months ago rest-api 4 weeks ago shipping 2 months ago shortcodes 2 months ago theme-support 2 years ago tracks 3 months ago traits 5 years ago walkers 5 years ago wccom-site 4 weeks ago widgets 4 weeks ago class-wc-ajax.php 4 weeks ago class-wc-auth.php 1 year ago class-wc-autoloader.php 7 months ago class-wc-background-emailer.php 4 weeks ago class-wc-background-updater.php 5 years ago class-wc-brands-brand-settings-manager.php 1 year ago class-wc-brands-coupons.php 1 year ago class-wc-brands.php 4 months ago class-wc-breadcrumb.php 3 months ago class-wc-cache-helper.php 4 weeks ago class-wc-cart-fees.php 2 years ago class-wc-cart-session.php 2 months ago class-wc-cart-totals.php 10 months ago class-wc-cart.php 2 months ago class-wc-checkout.php 4 weeks ago class-wc-cli.php 9 months ago class-wc-comments.php 3 months ago class-wc-countries.php 4 weeks ago class-wc-coupon.php 4 weeks ago class-wc-customer-download-log.php 5 years ago class-wc-customer-download.php 1 year ago class-wc-customer.php 4 weeks ago class-wc-data-exception.php 8 years ago class-wc-data-store.php 3 years ago class-wc-datetime.php 4 years ago class-wc-deprecated-action-hooks.php 2 years ago class-wc-deprecated-filter-hooks.php 2 months ago class-wc-discounts.php 10 months ago class-wc-download-handler.php 1 year ago class-wc-emails.php 1 week ago class-wc-embed.php 1 year ago class-wc-form-handler.php 2 months ago class-wc-frontend-scripts.php 4 weeks ago class-wc-geo-ip.php 7 months ago class-wc-geolite-integration.php 6 years ago class-wc-geolocation.php 4 weeks ago class-wc-https.php 2 years ago class-wc-install.php 1 week ago class-wc-integrations.php 5 years ago class-wc-log-levels.php 2 years ago class-wc-logger.php 3 months ago class-wc-meta-data.php 4 years ago class-wc-order-factory.php 4 weeks ago class-wc-order-item-coupon.php 4 years ago class-wc-order-item-fee.php 4 months ago class-wc-order-item-meta.php 4 years ago class-wc-order-item-product.php 4 weeks ago class-wc-order-item-shipping.php 4 months ago class-wc-order-item-tax.php 4 years ago class-wc-order-item.php 4 months ago class-wc-order-query.php 3 months ago class-wc-order-refund.php 1 year ago class-wc-order.php 3 weeks ago class-wc-payment-gateways.php 4 weeks ago class-wc-payment-tokens.php 3 years ago class-wc-post-data.php 4 weeks ago class-wc-post-types.php 4 weeks ago class-wc-privacy-background-process.php 1 year ago class-wc-privacy-erasers.php 9 months ago class-wc-privacy-exporters.php 4 years ago class-wc-privacy.php 11 months ago class-wc-product-attribute.php 3 months ago class-wc-product-download.php 3 months ago class-wc-product-external.php 1 year ago class-wc-product-factory.php 2 months ago class-wc-product-grouped.php 2 months ago class-wc-product-query.php 3 months ago class-wc-product-simple.php 10 months ago class-wc-product-variable.php 2 months ago class-wc-product-variation.php 1 year ago class-wc-query.php 4 weeks ago class-wc-rate-limiter.php 4 years ago class-wc-regenerate-images-request.php 3 years ago class-wc-regenerate-images.php 1 year ago class-wc-register-wp-admin-settings.php 4 years ago class-wc-rest-authentication.php 1 year ago class-wc-rest-exception.php 5 years ago class-wc-session-handler.php 2 months ago class-wc-shipping-rate.php 11 months ago class-wc-shipping-zone.php 5 years ago class-wc-shipping-zones.php 6 months ago class-wc-shipping.php 4 weeks ago class-wc-shortcodes.php 1 year ago class-wc-structured-data.php 4 weeks ago class-wc-tax.php 4 weeks ago class-wc-template-loader.php 6 months ago class-wc-tracker.php 7 months ago class-wc-validation.php 2 years ago class-wc-webhook.php 4 weeks ago class-woocommerce.php 1 week ago wc-account-functions.php 6 months ago wc-attribute-functions.php 4 weeks ago wc-brands-functions.php 1 year ago wc-cart-functions.php 4 months ago wc-conditional-functions.php 10 months ago wc-core-functions.php 4 weeks ago wc-coupon-functions.php 4 months ago wc-deprecated-functions.php 3 months ago wc-formatting-functions.php 6 months ago wc-interactivity-api-functions.php 4 weeks ago wc-notice-functions.php 4 months ago wc-order-functions.php 3 weeks ago wc-order-item-functions.php 3 years ago wc-order-step-logger-functions.php 3 months ago wc-page-functions.php 3 weeks ago wc-product-functions.php 4 weeks ago wc-rest-functions.php 6 months ago wc-stock-functions.php 6 months ago wc-template-functions.php 4 weeks ago wc-template-hooks.php 9 months ago wc-term-functions.php 4 weeks ago wc-update-functions.php 1 week ago wc-user-functions.php 4 weeks ago wc-webhook-functions.php 4 weeks ago wc-widget-functions.php 5 years ago
class-wc-background-emailer.php
189 lines
1 <?php
2 /**
3 * Background Emailer
4 *
5 * @version 3.0.1
6 * @package WooCommerce\Classes
7 */
8
9 use Automattic\Jetpack\Constants;
10
11 defined( 'ABSPATH' ) || exit;
12
13 if ( ! class_exists( 'WC_Background_Process', false ) ) {
14 include_once dirname( __FILE__ ) . '/abstracts/class-wc-background-process.php';
15 }
16
17 /**
18 * WC_Background_Emailer Class.
19 *
20 * @deprecated 10.8.0 Deferred emails now use Action Scheduler. No stable public replacement exists.
21 */
22 class WC_Background_Emailer extends WC_Background_Process {
23
24 /**
25 * Initiate new background process.
26 */
27 public function __construct() {
28 // Uses unique prefix per blog so each blog has separate queue.
29 $this->prefix = 'wp_' . get_current_blog_id();
30 $this->action = 'wc_emailer';
31
32 // Dispatch queue after shutdown.
33 add_action( 'shutdown', array( $this, 'dispatch_queue' ), 100 );
34
35 parent::__construct();
36 }
37
38 /**
39 * Schedule fallback event.
40 */
41 protected function schedule_event() {
42 if ( ! wp_next_scheduled( $this->cron_hook_identifier ) ) {
43 wp_schedule_event( time() + 10, $this->cron_interval_identifier, $this->cron_hook_identifier );
44 }
45 }
46
47 /**
48 * Task
49 *
50 * Override this method to perform any actions required on each
51 * queue item. Return the modified item for further processing
52 * in the next pass through. Or, return false to remove the
53 * item from the queue.
54 *
55 * @param array $callback Update callback function.
56 * @return mixed
57 */
58 protected function task( $callback ) {
59 if ( isset( $callback['filter'], $callback['args'] ) ) {
60 try {
61 WC_Emails::send_queued_transactional_email( $callback['filter'], $callback['args'] );
62 } catch ( Exception $e ) {
63 if ( Constants::is_true( 'WP_DEBUG' ) ) {
64 trigger_error( 'Transactional email triggered fatal error for callback ' . esc_html( $callback['filter'] ), E_USER_WARNING ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
65 }
66 }
67 }
68 return false;
69 }
70
71 /**
72 * Finishes replying to the client, but keeps the process running for further (async) code execution.
73 *
74 * @see https://core.trac.wordpress.org/ticket/41358 .
75 */
76 protected function close_http_connection() {
77 // Only 1 PHP process can access a session object at a time, close this so the next request isn't kept waiting.
78 // @codingStandardsIgnoreStart
79 if ( session_id() ) {
80 session_write_close();
81 }
82 // @codingStandardsIgnoreEnd
83
84 wc_set_time_limit( 0 );
85
86 // fastcgi_finish_request is the cleanest way to send the response and keep the script running, but not every server has it.
87 if ( is_callable( 'fastcgi_finish_request' ) ) {
88 fastcgi_finish_request();
89 } else {
90 // Fallback: send headers and flush buffers.
91 if ( ! headers_sent() ) {
92 header( 'Connection: close' );
93 }
94 @ob_end_flush(); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
95 flush();
96 }
97 }
98
99 /**
100 * Save and run queue.
101 */
102 public function dispatch_queue() {
103 if ( ! empty( $this->data ) ) {
104 $this->close_http_connection();
105 $this->save()->dispatch();
106 }
107 }
108
109 /**
110 * Get post args
111 *
112 * @return array
113 */
114 protected function get_post_args() {
115 if ( property_exists( $this, 'post_args' ) ) {
116 return $this->post_args;
117 }
118
119 // Pass cookies through with the request so nonces function.
120 $cookies = array();
121
122 foreach ( $_COOKIE as $name => $value ) { // WPCS: input var ok.
123 if ( 'PHPSESSID' === $name ) {
124 continue;
125 }
126 $cookies[] = new WP_Http_Cookie( array(
127 'name' => $name,
128 'value' => $value,
129 ) );
130 }
131
132 return array(
133 'timeout' => 0.01,
134 'blocking' => false,
135 'body' => $this->data,
136 'cookies' => $cookies,
137 'sslverify' => apply_filters( 'https_local_ssl_verify', false ),
138 );
139 }
140
141 /**
142 * Handle
143 *
144 * Pass each queue item to the task handler, while remaining
145 * within server memory and time limit constraints.
146 */
147 protected function handle() {
148 $this->lock_process();
149
150 do {
151 $batch = $this->get_batch();
152
153 if ( empty( $batch->data ) ) {
154 break;
155 }
156
157 foreach ( $batch->data as $key => $value ) {
158 $task = $this->task( $value );
159
160 if ( false !== $task ) {
161 $batch->data[ $key ] = $task;
162 } else {
163 unset( $batch->data[ $key ] );
164 }
165
166 // Update batch before sending more to prevent duplicate email possibility.
167 $this->update( $batch->key, $batch->data );
168
169 if ( $this->time_exceeded() || $this->memory_exceeded() ) {
170 // Batch limits reached.
171 break;
172 }
173 }
174 if ( empty( $batch->data ) ) {
175 $this->delete( $batch->key );
176 }
177 } while ( ! $this->time_exceeded() && ! $this->memory_exceeded() && ! $this->is_queue_empty() );
178
179 $this->unlock_process();
180
181 // Start next batch or complete process.
182 if ( ! $this->is_queue_empty() ) {
183 $this->dispatch();
184 } else {
185 $this->complete();
186 }
187 }
188 }
189