Am I the only one who always at the beginning of a project ends up with the "white page of death"?
This happens to me almost consistently when starting a new project with Yii…
For example, when overriding CController::beforeAction(), I frequently forget that you have to call parent::beforeAction() … which results in a blank page.
Or when working with filters - and forgetting to fire the call that triggers the filter chain continuation.
There are other marginal cases too.
Is there anything worse than the white page of death? It’s so spooky, it just should not happen - at the end of an HTTP request, you should have something return from the server.
In CWebApplication, how about adding a check at the end of run() to see if the request returned any output at all?
If the application produced no output, not even a header, then it should be safe to throw a 500 Internal Sever error - so that at least the developer knows that PHP and the web-server is still working, that Yii is still being dispatched, that there is still some form of order to the universe.
What do you think?
I usually put this in my htaccess:
php_flag display_errors on
And/or adjust the php.ini.
I don’t want any errors in production output, of course.
I also sometimes enclose the yii app run code in a try catch block so that I can display a generic error page, for production.
Would be nice if Yii can be configured to do that ‘out-of-the-box’, of course.
Shouldn’t happen in your development environment with error_reporting turned on.
But it does - consistently, always has.
Certain situations lead to a “dead end” where the script doesn’t fail or throw an exception, it just doesn’t do anything. What I’d like to do is check for “dead ends” after the application runs, and produce a default response if/when that happens.
I can just implement that of course, but it would be convenient if the framework did that out of the box.
I guess this can happen if you issue an exit for example - no output at all…
But what if for any "strange" reason this is intended by the developer… if Yii would check this and would issue an exception or anything else than that would not be expected at that situation.
Strictly speaking that’s not 500 and not an error at all. As mdomba pointed out, it can be desired behavior and existing applications can possibly rely on it.