Fix #2712

https://github.com/yiisoft/yii2/issues/2712