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

[5.4] Ensure Mailable view data is not overridden by order of operations #18322

Merged
merged 2 commits into from
Mar 13, 2017
Merged

Conversation

jameshulse
Copy link
Contributor

@jameshulse jameshulse commented Mar 13, 2017

The markdown(), view() and text() methods on the Mailable class currently override the instances viewData field with their own data parameter (which defaults to an empty array).

This means if any of these methods are called after the with() method that the previous view data supplied in the call to with() is lost.

In the following case the view data is empty:

public function build()
{
    $this->view('sample-view')
         ->with([ 'data' => 'example' ])
         ->text('sample-view_plain');
}

This pull request ensures the viewData is always merged with each subsequent call.

Unit tests are provided which exhibit the incorrect behaviour.

@taylorotwell taylorotwell merged commit b842085 into laravel:5.4 Mar 13, 2017
@jameshulse
Copy link
Contributor Author

Thanks @taylorotwell. I can fix the styling issue if you'd like - I'm afraid I didn't run a linter but I'll know for next time :)

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.

2 participants