awesomemotive / wp-mail-logging

:envelope: Logs each email sent by WordPress.
49 stars 26 forks source link

Logger breaks if no array passed from wp_mail #167

Closed donmhico closed 1 year ago

donmhico commented 1 year ago

Description

This PR fixes the issue where wp_mail triggers a fatal error if a non-array value is passed in wp_mail filter. In general, passing a null or non array value to wp_mail shouldn't be encouraged but such case should not trigger a fatal error just like how it works if WP Mail Logging plugin is not activated.

Motivation

Fixes #94.

Testing and procedure.

  1. Enable debugging logs.
  2. Add this snippet to your functions.php or anywhere that it'll run.
    add_filter( 'wp_mail', function(){ return null; } );
  3. Try to send an email.
  4. You shouldn't see a new mail log on WP Mail Logging logs page but you should not also see a fatal error log.