• Resolved jibbius

    (@jibbius)


    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;
    }
    }
    • This topic was modified 3 weeks, 1 day ago by jibbius.
Viewing 1 replies (of 1 total)
  • Plugin Author Michael

    (@donmhico)

    Hello @jibbius,

    Thank you for bringing this up and we definitely appreciate that you provide the fix. We’ll definitely include this in the next release!

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.