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
This commit is contained in:
parent
ba039f7546
commit
dab566d973
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue