mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 06:15:19 +08:00
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:

committed by
Alexander Makarov

parent
ecf3ef8bf9
commit
24f4e3126a
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user