From 84702f1e6f00647898b5365e1575d95da79688bc Mon Sep 17 00:00:00 2001 From: AnatolyRugalev Date: Tue, 15 Dec 2015 12:12:27 +0500 Subject: [PATCH 1/3] 1. Added init() warning to session component 2. register_shutdown_function() for Session::close now only calls after successful session open --- framework/web/Session.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/framework/web/Session.php b/framework/web/Session.php index ce18ac3a03..acb039e94a 100644 --- a/framework/web/Session.php +++ b/framework/web/Session.php @@ -96,7 +96,9 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co public function init() { parent::init(); - register_shutdown_function([$this, 'close']); + if ($this->getIsActive()) { + Yii::warning("Session is already started", __METHOD__); + } } /** @@ -129,6 +131,7 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co if ($this->getIsActive()) { Yii::info('Session started', __METHOD__); $this->updateFlashCounters(); + register_shutdown_function([$this, 'close']); } else { $error = error_get_last(); $message = isset($error['message']) ? $error['message'] : 'Failed to start session.'; From c9463235d1608ff8b703420fe0c6ed148daf0a99 Mon Sep 17 00:00:00 2001 From: AnatolyRugalev Date: Tue, 15 Dec 2015 12:15:17 +0500 Subject: [PATCH 2/3] Added changelog line --- framework/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 19ba701dcd..673091ba4e 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -78,6 +78,7 @@ Yii Framework 2 Change Log - Enh #10158: Added the possibility to specify CSS and Javascript options per file in `\yii\web\AssetBundle` (machour) - Enh #10170: `Yii::powered()` now uses `Yii::t()` (SamMousa) - Enh #10218: Support for selecting multiple filter values with the same name was added to `yii.gridView.js` (omnilight, silverfire) +- Enh #10255: Added Yii warning to session initialization if session was already started (AnatolyRugalev) - Enh #10264: Generation of HTML tags in Yii's JavaScript now uses jQuery style (silverfire) - Enh #10267: `yii.js` - added original event passing to `pjaxOptions` for links with `data-method` and `data-pjax` (servocoder, silverfire) - Enh #10319: `yii\helpers\VarDumper::dump()` now respects PHP magic method `__debugInfo()` (klimov-paul) From c39c0b3ddd9b97ce892c85c1d2a143d4c265e13f Mon Sep 17 00:00:00 2001 From: AnatolyRugalev Date: Fri, 18 Dec 2015 17:28:58 +0500 Subject: [PATCH 3/3] returned shutdown handler to it's original place --- framework/web/Session.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/web/Session.php b/framework/web/Session.php index acb039e94a..0e604f6b7a 100644 --- a/framework/web/Session.php +++ b/framework/web/Session.php @@ -96,6 +96,7 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co public function init() { parent::init(); + register_shutdown_function([$this, 'close']); if ($this->getIsActive()) { Yii::warning("Session is already started", __METHOD__); } @@ -131,7 +132,6 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co if ($this->getIsActive()) { Yii::info('Session started', __METHOD__); $this->updateFlashCounters(); - register_shutdown_function([$this, 'close']); } else { $error = error_get_last(); $message = isset($error['message']) ? $error['message'] : 'Failed to start session.';