Bug #15523: yii\web\Session settings could now be configured after session is started (StalkAlex, rob006, daniel1302, samdark)

Co-authored-by: Alexander Makarov <sam@rmcreative.ru>
Co-authored-by: Robert Korulczyk <robert@korulczyk.pl>
Co-authored-by: daniel.1302 <daniel.1302@gmail.com>
This commit is contained in:
Alexander
2018-02-08 22:11:45 +05:00
committed by Alexander Makarov
parent ecf3ef8bf9
commit 24f4e3126a
5 changed files with 106 additions and 3 deletions

View File

@ -13,6 +13,7 @@ use yii\db\Connection;
use yii\db\PdoValue;
use yii\db\Query;
use yii\di\Instance;
use yii\helpers\ArrayHelper;
/**
* DbSession extends [[Session]] by using database as session data storage.
@ -81,10 +82,12 @@ class DbSession extends MultiFieldSession
* This method will initialize the [[db]] property to make sure it refers to a valid DB connection.
* @throws InvalidConfigException if [[db]] is invalid.
*/
public function init()
public function __construct(array $config = [])
{
parent::init();
$this->db = Instance::ensure($this->db, Connection::className());
// db component should be initialized before configuring DbSession component
// @see https://github.com/yiisoft/yii2/pull/15523#discussion_r166701079
$this->db = Instance::ensure(ArrayHelper::remove($config, 'db', $this->db), Connection::className());
parent::__construct($config);
}
/**