Fixes #3992
Fixes #4147
Merge branch 'master' of git://github.com/yiisoft/yii2