[REF] Remove illusion of looping #21554
Merged
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.
Overview
[REF] Remove illusion of looping
This foreach actually only copes with 1 value. Making that clearer makes it more readable
Before
It loops through the attachments if any but only uses the 'last one'
After
It explicitly only grabs the first one
Technical Details
If the data model only copes with 1 then I don't think first vs last is material - the reality is it works with up to 1 attachment & clarifying that now means we don't have to later....
Most of this handling seems to be because it could be NULL rather than an array
This functionality appears to be about allowing an attachment to be the message template - ie upload a doc as a template rather than save a message template - so more than 1 file makes no sense
Comments