{"action":"opened","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/13251","repository_url":"https://api.github.com/repos/yiisoft/yii2","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/13251/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/13251/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/13251/events","html_url":"https://github.com/yiisoft/yii2/issues/13251","id":196563661,"number":13251,"title":"session setFlash can't work when happend \\yii\\db\\IntegrityException","user":{"login":"pigochu","id":1013744,"avatar_url":"https://avatars.githubusercontent.com/u/1013744?v=3","gravatar_id":"","url":"https://api.github.com/users/pigochu","html_url":"https://github.com/pigochu","followers_url":"https://api.github.com/users/pigochu/followers","following_url":"https://api.github.com/users/pigochu/following{/other_user}","gists_url":"https://api.github.com/users/pigochu/gists{/gist_id}","starred_url":"https://api.github.com/users/pigochu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pigochu/subscriptions","organizations_url":"https://api.github.com/users/pigochu/orgs","repos_url":"https://api.github.com/users/pigochu/repos","events_url":"https://api.github.com/users/pigochu/events{/privacy}","received_events_url":"https://api.github.com/users/pigochu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-12-20T01:31:39Z","updated_at":"2016-12-20T01:31:39Z","closed_at":null,"body":"- PHP version 7.0.10\r\n- YII version 2.0.10\r\n- OS: Windows 10\r\n\r\nThis is my code :\r\n~~~php\r\n    public function actionDelete($id) {\r\n        try{\r\n            $this->findModel($id)->delete();\r\n            Yii::$app->session->setFlash('success' , 'Delete ok。');\r\n            return $this->redirect(['index']);\r\n        } catch (\\yii\\db\\IntegrityException $e) {\r\n            Yii::$app->session->setFlash('error' , 'Delete error。');\r\n        }\r\n        return $this->redirect(['view' , 'id' => $id]);\r\n    }\r\n~~~\r\n\r\nif delete success , the \"success flash message\" will be render in action \"index\"\r\nif delete happend exception , the \"error flash message\" will not be render in 'view' action.\r\n\r\nbut when I add two line \r\n~~~php\r\n    public function actionDelete($id) {\r\n       // add two line here\r\n        Yii::$app->session->setFlash('error' , 'Delete error。');\r\n        return $this->redirect(['view' , 'id' => $id]);\r\n        try{\r\n            $this->findModel($id)->delete();\r\n            Yii::$app->session->setFlash('success' , 'Delete ok。');\r\n            return $this->redirect(['index']);\r\n        } catch (\\yii\\db\\IntegrityException $e) {\r\n            Yii::$app->session->setFlash('error' , 'Delete error。');\r\n        }\r\n        return $this->redirect(['view' , 'id' => $id]);\r\n    }\r\n~~~\r\n\r\nthe error flash message be rendered ...... why ? :(\r\n"}}
{"actor":{"display_login":"pigochu"}}