Closed mikehaertl closed 7 years ago
could you create a failing unit test for this?
Sorry, will not find time for a unit test. It's not a simple test as you somehow have to capture/compare web output. No idea how to handle this in a unit test.
This issue does not belong to yii2-swiftmailer
it is a general problem of yii\base\View::render()
.
To reproduce: 1) Create web controller action:
public function actionRender()
{
try {
return $this->render('exception');
} catch (\Exception $e) {
return $this->render('index');
}
}
2) Create view file exception.php
:
<h1>File Begin</h1>
<?php throw new Exception('test'); ?>
<h1>File End</h1>
The first line in rendered page will be <h1>File Begin</h1>
Migrated to https://github.com/yiisoft/yii2/issues/13058
What steps will reproduce the problem?
Render a faulty mail message that throws a Swift exception. For example attach a file that does not exist.
What's expected?
If you catch the exception, no extra output should be generated on the web page.
What do you get instead?
When rendering the mail body, PHP output buffering is used. When the exception is thrown, the buffer is obviously not cleared correctly. So the parts of the mail that rendered successful before the exception happened now appear in the web output, even when you catch the exception.
Additional info