Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix headers information not displayed #145

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

benoitchantre
Copy link
Contributor

When logs are enabled, the information box should display the email headers. This was not the case.

Closes #114.

@soup-bowl
Copy link
Owner

This seems to break in the scenario when the headers are stored as a string array (triggered by sending a test email).

image

Perhaps it would be helpful to mention what plugin is having problems with mail log display?

@benoitchantre
Copy link
Contributor Author

Thank you for the feedbacks.

I get PHP warnings from this plugin on many sites when logs are turned on (see #114). Those are maintained sites running the latest version of WP Simple SMTP and WordPress, with PHP 8.0 or PHP 8.1 and MariaDB 10.4

I’ll do more tests.

@soup-bowl
Copy link
Owner

soup-bowl commented Aug 23, 2023

From reading the WordPress Core code on wp mail, see if this works on an unmodified version. I'm still somewhat operating blind until I know what plugin is causing this.

in src/log/class-log.php line 151

/**
* Gets the server dispatch headers.
*
* @return string|string[]
*/
public function get_headers() {
  if ( ! is_array( $this->headers ) ) {
    return explode( "\n", str_replace( "\r\n", "\n", $this->headers ) );
  } else {
    return $this->headers;
  }
}

I tried your mentioned setup in a Docker environment, and I was not able to replicate the issue - sending a test mail, the headers were a string array.

@benoitchantre
Copy link
Contributor Author

I wanted to come back earlier but had not time to investigate more. My latest test showed a difference between test emails and regular emails sent by WordPress, but both have valid headers (string or array). Then I did a test with Gravity Forms and saw headers saved in an object instead of an array.

@soup-bowl
Copy link
Owner

Not a worry. I'll do some digging later with your updated info. The snippet I provided might not work anyway due to how the log object conversion occurs, but I've run out of time to debug at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid argument supplied for foreach
2 participants