PHP E_WARNING (#2): Undefined array key 0 : WPML_Plugin.php (587)
-
I am getting the following warning, after updating to v1.13.1:
PHP E_WARNING (#2): Undefined array key 0
wp-content/plugins/wp-mail-logging/src/WPML_Plugin.php (587)The offending code is trying to read from an array, but is incorrectly using a numeric index.
The array’s keys are set to values such as From and CC.var_dump($mail_headers) ...
array (
'From' => 'From: [email protected]',
'Cc' => 'Cc: ',
'Bcc' => 'Bcc: [email protected]',
'Content-type' => 'Content-type: text/html; charset=UTF-8',
)I think the fix should be as follows:
// BEFORE:
for ( $ctr = 0; $ctr < count( $mail_headers ); $ctr++ ) {
$header_arr = explode( ":", $mail_headers[ $ctr ] );
// If Content-Type header is already set, don't add it again.
if ( ! empty( $header_arr[0] ) && strtolower( $header_arr[0] ) === 'content-type' ) {
$should_force_add_content_type = false;
}
}// AFTER:
foreach ( $mail_headers as $mail_header ) {
$header_arr = explode( ":", $mail_header );
// If Content-Type header is already set, don't add it again.
if ( ! empty( $header_arr[0] ) && strtolower( $header_arr[0] ) === 'content-type' ) {
$should_force_add_content_type = false;
break;
}
}
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- You must be logged in to reply to this topic.