Resolves #582 - Default to returning all parts, add allow_single_parts op… #583
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I implemented a fix here for Issue 582 and related (issues of bodies not being decoded etc) as follows:
Added new config option, "allow_single_parts", bool defaulting to true
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.