From 180f5cd40bf1c59ea089c35616400aefe9b5b034 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Thu, 13 Apr 2017 14:22:07 +0100 Subject: [PATCH 1/2] send_transactional_email try catch block --- includes/class-wc-emails.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/includes/class-wc-emails.php b/includes/class-wc-emails.php index f90217a0111..ff924d7b37e 100644 --- a/includes/class-wc-emails.php +++ b/includes/class-wc-emails.php @@ -139,9 +139,15 @@ class WC_Emails { * @param array $args Email args (default: []). */ public static function send_transactional_email( $args = array() ) { - $args = func_get_args(); - self::instance(); // Init self so emails exist. - do_action_ref_array( current_filter() . '_notification', $args ); + try { + $args = func_get_args(); + self::instance(); // Init self so emails exist. + do_action_ref_array( current_filter() . '_notification', $args ); + } catch ( Exception $e ) { + if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { + trigger_error( 'Transactional email triggered fatal error for callback ' . current_filter(), E_USER_WARNING ); + } + } } /** From 77d93a70e0b5f672ddff38e028648268226ac446 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Thu, 13 Apr 2017 14:22:33 +0100 Subject: [PATCH 2/2] Set woocommerce_defer_transactional_emails to false by default --- includes/class-wc-emails.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-wc-emails.php b/includes/class-wc-emails.php index ff924d7b37e..99f2873b6f4 100644 --- a/includes/class-wc-emails.php +++ b/includes/class-wc-emails.php @@ -88,7 +88,7 @@ class WC_Emails { 'woocommerce_created_customer', ) ); - if ( apply_filters( 'woocommerce_defer_transactional_emails', true ) ) { + if ( apply_filters( 'woocommerce_defer_transactional_emails', false ) ) { self::$background_emailer = new WC_Background_Emailer(); foreach ( $email_actions as $action ) {