File tree Expand file tree Collapse file tree 2 files changed +3
-12
lines changed Expand file tree Collapse file tree 2 files changed +3
-12
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ Yii Framework 2 redis extension Change Log
4
4
2.0.12 under development
5
5
------------------------
6
6
7
- - no changes in this release.
7
+ - Enh # 195 : Use ` Instance::ensure() ` to initialize ` Session::$redis ` (rob006)
8
8
9
9
10
10
2.0.11 November 05, 2019
Original file line number Diff line number Diff line change 9
9
10
10
use Yii ;
11
11
use yii \base \InvalidConfigException ;
12
+ use yii \di \Instance ;
12
13
13
14
/**
14
15
* Redis Session implements a session component using [redis](http://redis.io/) as the storage medium.
@@ -79,17 +80,7 @@ class Session extends \yii\web\Session
79
80
*/
80
81
public function init ()
81
82
{
82
- if (is_string ($ this ->redis )) {
83
- $ this ->redis = Yii::$ app ->get ($ this ->redis );
84
- } elseif (is_array ($ this ->redis )) {
85
- if (!isset ($ this ->redis ['class ' ])) {
86
- $ this ->redis ['class ' ] = Connection::className ();
87
- }
88
- $ this ->redis = Yii::createObject ($ this ->redis );
89
- }
90
- if (!$ this ->redis instanceof Connection) {
91
- throw new InvalidConfigException ("Session::redis must be either a Redis connection instance or the application component ID of a Redis connection. " );
92
- }
83
+ $ this ->redis = Instance::ensure ($ this ->redis , Connection::className ());
93
84
if ($ this ->keyPrefix === null ) {
94
85
$ this ->keyPrefix = substr (md5 (Yii::$ app ->id ), 0 , 5 );
95
86
}
You can’t perform that action at this time.
0 commit comments