trejder
trejder

Reputation: 17495

Yii2 error handler dies ugly on non-object calls

Can anyone have any idea, what can cause Yii2 error handler to halt correctly on following line:

echo $missing;

(assuming, that $missing is null) and display correctly "Undefined variable: missing..." notice. And in the same time "die" totally on following line:

echo $missing->noneExisting();

and display (return) completely blank page instead of correct error message?

I have a very strange troubles with Yii2 error handler ever since I started coding in Yii2. Above code is one of examples. Another one is, that redeclaring Yii namespace in migration causes command-line console to die ugly, instead of displaying proper fatal error.

I've been told, that this problem is caused by my PHP configuration. But I found it hard to believe -- mainly because:

I agree, that this must be something in my local installation of PHP, because I have tested all of these examples in freshly-new installed XAMPP 5.6.8 and in its portable version. But, since I can only reproduce this problem in Yii2-powered project and everything goes as good as it can in Yii1-powered application or under pure PHP, then there must be some sort of nasty devil inside.

Can someone help here or at least shed some light, where should I start looking for?

Upvotes: 4

Views: 518

Answers (1)

XzAeRo
XzAeRo

Reputation: 566

I found out that on certain environments, when Yii2 handles a missing variable error, it shows an error at the bottom of the debugger.

Warning: var_export does not handle circular references in ~/vendor/yiisoft/yii2/helpers/BaseVarDumper.php on line 187

Maybe that error is causing your environment to die on this. However this seems to be a bug.

Also, I found a workaround using the solution found in this Github Issue. It's not pretty, but is a solution.

Edit: A patch for this issue was released. See here

Upvotes: 1

Related Questions