Skip to content

Resolves #582 - Default to returning all parts, add allow_single_parts op… #583

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mrhewitt
Copy link

I implemented a fix here for Issue 582 and related (issues of bodies not being decoded etc) as follows:

  1. Added new config option, "allow_single_parts", bool defaulting to true

  2. Altered Structure::parsePart to alter "fix" commited in issue Fix bug when multipart message getHTMLBody() method returns null #455 to rather be:

if ( count($parts) > 1 || $config->get("options")['allow_single_parts'] ) {

This will now always return parts if there are multiple but allows it to optionally also return if only a single part is found.

I believe the default here should be true (always return recursive part even if only one part is found in a multipart block) as this how it operated for years before, and it would seem in most cases looking at all issues raised since this commit was pulled in this is valid behavior (otherwise we get undecoded parts).

For edge cases such as experienced by @michalkortas there is the possiblity of setting "allow_single_parts" to false in thier configuration, thus still achieving what they set out to in the PR but in a way that does not affect most users.

@mrhewitt mrhewitt changed the title Issue 582 - Default to returning all parts, add allow_single_parts op… Resolves #582 - Default to returning all parts, add allow_single_parts op… May 30, 2025
Copy link

@ETES-Stuttgart ETES-Stuttgart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested this change and can confirm that it also fixes issue #580.

// we return these parts if there are multiple or if configured to allow a single part here (default)
// isolated cases a single part here causes an empty body, to workaround this set
// allow_single_parts to false in your config
if ( count($parts) > 1 || $config->get("options")['allow_single_parts'] ) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ( count($parts) > 1 || $config->get("options")['allow_single_parts'] ) {
if ( count($parts) > 1 || $config->get("options.allow_single_parts") ) {

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.

3 participants