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
442.0.12 under development
55------------------------
66
7- - no changes in this release.
7+ - Enh # 195 : Use ` Instance::ensure() ` to initialize ` Session::$redis ` (rob006)
88
99
10102.0.11 November 05, 2019
Original file line number Diff line number Diff line change 99
1010use Yii ;
1111use yii \base \InvalidConfigException ;
12+ use yii \di \Instance ;
1213
1314/**
1415 * 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
7980 */
8081 public function init ()
8182 {
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 ());
9384 if ($ this ->keyPrefix === null ) {
9485 $ this ->keyPrefix = substr (md5 (Yii::$ app ->id ), 0 , 5 );
9586 }
You can’t perform that action at this time.
0 commit comments