Fatal error not handled
-
I was testing with plugins and I have WP Mail Logging by MailPoet installed and was experimenting with Disable Emails.
After enabling Disable Emails, when I select a mail in WP Mail Logging’s mail log (checkbox) and choose the bulk action “resend”, your plugin throws an unhandled fatal error. Yes, I realize trying to send mail when it’s disabled is stupid, but bear with me please.
So the mail logging plugin tries to resend the mail, with an $attachments variable that is “” (a 0-byte string), which is then exploded on “\n” (just like WP core does) resulting in an array with 1 item (so not an empty array, even though the 1 item is a 0-byte string). Your plugin has set up $phpmailer as PHPMailerMock, and when it reaches the part for handling attachments, it calls
$this->phpmailer->AddAttachment($attachment);
which then expectedly throws aphpmailerException
(because an empty string is not an existing file). This is good.However, while you do have a try/catch for
phpmailerException
in your plugin, it doesn’t work, because “phpmailerException” is an undefined class. You need to adduse \phpmailerException;
to the top of your mock file be able to catch phpmailerException exceptions.See? I did something stupid, but found a bug that’s not stupid. ??
- The topic ‘Fatal error not handled’ is closed to new replies.