From dab566d9738c96ebe8a3c6d3de7428359ecf27a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helen=20Hou-Sand=C3=AD?= Date: Wed, 2 Nov 2016 04:27:34 +0000 Subject: [PATCH] Mail: Set a better error code when triggering `wp_mail_failed`. This error code is now... wait for it... `wp_mail_failed`. Previously, this would have been the originating PHPMailer error code, which could be `0`, which would then fail (pass?) the `empty()` check in the `WP_Error` constructor, thereby rendering the error object fairly useless. The PHPMailer error code is now located within the `WP_Error` data. props Kau-Boy, stephenharris. fixes #35598. Built from https://develop.svn.wordpress.org/trunk@39086 git-svn-id: http://core.svn.wordpress.org/trunk@39028 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/pluggable.php | 5 +++-- wp-includes/version.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index fcc92fb71c..ef731793ef 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -472,16 +472,17 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() } catch ( phpmailerException $e ) { $mail_error_data = compact( 'to', 'subject', 'message', 'headers', 'attachments' ); + $mail_error_data['phpmailer_exception_code'] = $e->getCode(); /** * Fires after a phpmailerException is caught. * * @since 4.4.0 * - * @param WP_Error $error A WP_Error object with the phpmailerException code, message, and an array + * @param WP_Error $error A WP_Error object with the phpmailerException message, and an array * containing the mail recipient, subject, message, headers, and attachments. */ - do_action( 'wp_mail_failed', new WP_Error( $e->getCode(), $e->getMessage(), $mail_error_data ) ); + do_action( 'wp_mail_failed', new WP_Error( 'wp_mail_failed', $e->getMessage(), $mail_error_data ) ); return false; } diff --git a/wp-includes/version.php b/wp-includes/version.php index d6d07c2e5c..6c0387b459 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.7-beta1-39085'; +$wp_version = '4.7-beta1-39086'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.