awesomemotive / wp-mail-logging

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

Always produce warning messages after Build v1.13.0 on PHP 8 #196

Closed isheik closed 2 weeks ago

isheik commented 1 month ago

Hi,

I am getting the warning messages below whenever I send emails from my site.

[23-Oct-2024 23:32:46 UTC] PHP Warning: Undefined array key 0 in [siteroot]\wp-content\plugins\wp-mail-logging\src\WPML_Plugin.php on line 587 [23-Oct-2024 23:32:46 UTC] PHP Warning: Undefined array key 1 in [siteroot]\wp-content\plugins\wp-mail-logging\src\WPML_Plugin.php on line 587

This is because the new codes added in Build v1.13.0 (line 566 in the link below) is trying to access an associative array which has string keys by index numbers, which causes "Undefined array key" error that changed to issues E_WARNING error since PHP 8. https://github.com/awesomemotive/wp-mail-logging/commit/ccb6d3c3aa1f70230dee921b173d45ac9ac52b52#diff-55d0677ab1dca7e94b81dbbb0e2718f8832a0ab960b0740c3fd1bb0beffba91a

$header_arr = explode( ":", $mail_headers[ $ctr ] );

How to replicate the issue

  1. Update the site PHP version to PHP 8.x (I was using 8.0.28)
  2. Send an email with email headers from the WP site
isheik commented 2 weeks ago

The issue was closed by https://github.com/awesomemotive/wp-mail-logging/pull/197