Commit f3a6b198 by Carsten Brandt

do not call afterAction() if beforeAction returned false

fixes #5379
parent b9520596
...@@ -9,6 +9,7 @@ Yii Framework 2 Change Log ...@@ -9,6 +9,7 @@ Yii Framework 2 Change Log
- Bug #5314: Fixed typo in the implementation of `yii\web\Session::getHasSessionId()` (qiangxue) - Bug #5314: Fixed typo in the implementation of `yii\web\Session::getHasSessionId()` (qiangxue)
- Bug #5323: Nested dropdown does not work for `yii\bootstrap\DropDown` (aryraditya) - Bug #5323: Nested dropdown does not work for `yii\bootstrap\DropDown` (aryraditya)
- Bug #5336: `yii\bootstrap\DropDown` should register bootstrap plugin asset (zelenin) - Bug #5336: `yii\bootstrap\DropDown` should register bootstrap plugin asset (zelenin)
- Bug #5379: `Module::afterAction()` was called even when `beforeAction()` returned false (cebe)
- Bug: Date and time formatting now assumes UTC as the timezone for input dates unless a timezone is explicitly given (cebe) - Bug: Date and time formatting now assumes UTC as the timezone for input dates unless a timezone is explicitly given (cebe)
- Enh #4040: Added `$viewFile` and `$params` to the `EVENT_BEFORE_RENDER` and `EVENT_AFTER_RENDER` events for `View` (qiangxue) - Enh #4040: Added `$viewFile` and `$params` to the `EVENT_BEFORE_RENDER` and `EVENT_AFTER_RENDER` events for `View` (qiangxue)
- Enh #4275: Added `removeChildren()` to `yii\rbac\ManagerInterface` and implementations (samdark) - Enh #4275: Added `removeChildren()` to `yii\rbac\ManagerInterface` and implementations (samdark)
......
...@@ -134,6 +134,7 @@ class Controller extends Component implements ViewContextInterface ...@@ -134,6 +134,7 @@ class Controller extends Component implements ViewContextInterface
$modules = []; $modules = [];
$runAction = true; $runAction = true;
// call beforeAction on modules
foreach ($this->getModules() as $module) { foreach ($this->getModules() as $module) {
if ($module->beforeAction($action)) { if ($module->beforeAction($action)) {
array_unshift($modules, $module); array_unshift($modules, $module);
...@@ -145,17 +146,18 @@ class Controller extends Component implements ViewContextInterface ...@@ -145,17 +146,18 @@ class Controller extends Component implements ViewContextInterface
$result = null; $result = null;
if ($runAction) { if ($runAction && $this->beforeAction($action)) {
if ($this->beforeAction($action)) { // run the action
$result = $action->runWithParams($params); $result = $action->runWithParams($params);
$result = $this->afterAction($action, $result); $result = $this->afterAction($action, $result);
}
}
// call afterAction on modules
foreach ($modules as $module) { foreach ($modules as $module) {
/* @var $module Module */ /* @var $module Module */
$result = $module->afterAction($action, $result); $result = $module->afterAction($action, $result);
} }
}
$this->action = $oldAction; $this->action = $oldAction;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment