#37894 closed defect (bug) (duplicate)
WP_Error::__construct ignoring $message and $data when raised from exceptions without a code
| Reported by: | zw7 | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | General | Version: | 4.7 |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: |
Description
I ran into this problem while debugging wp_mail function:
line 483 of wp-includes/pluggable.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
if ( empty($code) && $code !== 0 ) return;
Change History (2)
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Duplicate of #35598.