Closed bragle closed 5 years ago
I'm actually not quite sure why I'm getting that error, but I suspect it might have something with running craft on windows. I'm using the lastest default LAMP stack on win 10 with xampp.
This is the the error message (printed below the page content):
`An Error occurred while handling another error: yii\web\HeadersAlreadySentException: Headers already sent in C:\xampp\htdocs\craft\vendor\bolden\htmlcache\src\services\HtmlcacheService.php on line 256. in C:\xampp\htdocs\craft\vendor\yiisoft\yii2\web\Response.php:366 Stack trace:
Previous exception: yii\web\HeadersAlreadySentException: Headers already sent in C:\xampp\htdocs\craft\vendor\bolden\htmlcache\src\services\HtmlcacheService.php on line 256. in C:\xampp\htdocs\craft\vendor\yiisoft\yii2\web\Response.php:366 Stack trace:
Not sure either. I suspect that there is an error happening but it cannot be displayed (cannot send headers) because the html cache plugin already sent content. Maybe you can figure out the error that is happening in your application.
You suggestion seems legit and it did not create any issues when I tested it. I will merge the code and release a new version.
BTW, you might want to change \Yii::$app
to \Craft::$app
. I don't believe it'll make any difference, but it might be nice for consistency.
Good point thanks. Although it should not matter as Craft extends Yii.
When using devmode, im getting a HeadersAlreadySent exception from Yii. This seems to fix it.
Alternatively, setting \Yii::$app->response->isSent to true before echoing the output will also work.