diff --git a/framework/web/Controller.php b/framework/web/Controller.php index 3f25f798cc..c249c9af71 100644 --- a/framework/web/Controller.php +++ b/framework/web/Controller.php @@ -105,7 +105,7 @@ class Controller extends \yii\base\Controller public function beforeAction($action) { if (parent::beforeAction($action)) { - if ($this->enableCsrfValidation && Yii::$app->errorHandler->exception === null && !Yii::$app->getRequest()->validateCsrfToken()) { + if ($this->enableCsrfValidation && Yii::$app->getErrorHandler()->exception === null && !Yii::$app->getRequest()->validateCsrfToken()) { throw new BadRequestHttpException(Yii::t('yii', 'Unable to verify your data submission.')); } return true; diff --git a/framework/web/ErrorAction.php b/framework/web/ErrorAction.php index ccba108fb5..a4cc7de43d 100644 --- a/framework/web/ErrorAction.php +++ b/framework/web/ErrorAction.php @@ -68,7 +68,7 @@ class ErrorAction extends Action public function run() { - if (($exception = Yii::$app->errorHandler->exception) === null) { + if (($exception = Yii::$app->getErrorHandler()->exception) === null) { return ''; }