[wp-trac] [WordPress Trac] #37894: WP_Error::__construct ignoring $message and $data when raised from exceptions without a code
WordPress Trac
noreply at wordpress.org
Wed Aug 31 14:05:32 UTC 2016
#37894: WP_Error::__construct ignoring $message and $data when raised from
exceptions without a code
--------------------------+-----------------------------
Reporter: zw7 | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: trunk
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
I ran into this problem while debugging wp_mail function:
line 483 of wp-includes/pluggable.php
{{{#!php
do_action( 'wp_mail_failed', new WP_Error( $e->getCode(),
$e->getMessage(), $mail_error_data ) );
}}}
WP_Error::construct ignores $message and $data parameters if $code
parameter is empty, however the whole phpmailer library throws exceptions
without the code parameter, making the Exception::getCode() function
return integer 0.
The problem could be solved by giving a custom error code in the wp_mail
function, but i believe this is a general problem that could be raised by
other sources, so we should also allow $code parameter in WP_Error
constructor to be equal to 0
Something like
{{{#!php
if ( empty($code) && $code !== 0 )
return;
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/37894>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list