-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[Mailer] Fix: do not clear context of message after rendering #48300
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
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e3a7411
Attempt context clearing for message sent to bus
silverbackdan bd5b6b1
Harden test to ensure messenger message can be serialized
silverbackdan 29ad664
Refactor test
silverbackdan fecc3a3
Adjust test name for further clarification of test goals
silverbackdan 33d927d
Add comment on clearing context in code
silverbackdan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's useful, see #47075 (comment) for the explanation of why we need to empty the context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably have a test covering that use case, to avoid regressions on that use case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, thanks for clarifying, I hadn't seen that.
I wonder whether by doing this we end up removing the context from the debug profiler as well though. I wonder if there is a way to keep this information in the logs/profiler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it perhaps be preferable to clear the context at the time of serializing for the messenger dispatch, perhaps by cloning the message and clearing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Omitting the context when serializing a TemplatedEmail that is already rendered might indeed be an option.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK cool, as I'm working in test environment for behat functional testing in my project, I don't have a test which triggers the PhpSerializer to serialize the envelope. I'll try and work out how to make a failing test in this PR when the context is not cleared first and then where (that would make sense) to hook in the logic to check for a TemplatedEmail before the serializer is called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the PR request to clear context before sending to the bus instead as an alternative option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your change would break valid use cases. There are 2 supported use cases: rendering emails before sending them to the bus and rendering them when consumed from the queue. So, we can only clear the context when the email is rendered, which is why the current code is here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there another alternative? This code change would break tests so would the advice to anyone upgrade from 6.1 to 6.2 be to adjust their tests and perhaps am I wrong in thinking that by clearing the context the profiler would not longer be able to output the context set in the email too?
Would the change in RC1 as it stands not constitute a breaking change?