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

Catched swift exception still messes up page output #38

Closed
mikehaertl opened this issue Nov 22, 2016 · 4 comments
Closed

Catched swift exception still messes up page output #38

mikehaertl opened this issue Nov 22, 2016 · 4 comments
Labels
status:to be verified Needs to be reproduced and validated. type:bug Bug

Comments

@mikehaertl
Copy link

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

Q A
Yii version 2.0.10
PHP version 7.0.8
Operating system Ubuntu 14.04 LTS
@cebe
Copy link
Member

cebe commented Nov 22, 2016

could you create a failing unit test for this?

@mikehaertl
Copy link
Author

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.

@klimov-paul klimov-paul added type:bug Bug status:to be verified Needs to be reproduced and validated. labels Nov 22, 2016
@klimov-paul
Copy link
Member

klimov-paul commented Nov 22, 2016

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');
        }
    }
  1. 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>

@klimov-paul
Copy link
Member

Migrated to yiisoft/yii2#13058

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:to be verified Needs to be reproduced and validated. type:bug Bug
Projects
None yet
Development

No branches or pull requests

3 participants