@@ -202,6 +202,7 @@ public static function createConnection(string $dsn, array $options = [])
202
202
do {
203
203
$ host = $ hosts [$ hostIndex ]['host ' ] ?? $ hosts [$ hostIndex ]['path ' ];
204
204
$ port = $ hosts [$ hostIndex ]['port ' ] ?? 0 ;
205
+ $ passAuth = \defined ('Redis::OPT_NULL_MULTIBULK_AS_NULL ' ) && isset ($ params ['auth ' ]);
205
206
$ address = false ;
206
207
207
208
if (isset ($ hosts [$ hostIndex ]['host ' ]) && $ tls ) {
@@ -211,11 +212,27 @@ public static function createConnection(string $dsn, array $options = [])
211
212
if (!isset ($ params ['redis_sentinel ' ])) {
212
213
break ;
213
214
}
214
- $ extra = [];
215
- if (\defined ('Redis::OPT_NULL_MULTIBULK_AS_NULL ' ) && isset ($ params ['auth ' ])) {
216
- $ extra = [$ params ['auth ' ]];
215
+
216
+ if (version_compare (phpversion ('redis ' ), '6.0.0 ' , '>= ' )) {
217
+ $ options = [
218
+ 'host ' => $ host ,
219
+ 'port ' => $ port ,
220
+ 'connectTimeout ' => $ params ['timeout ' ],
221
+ 'persistent ' => $ params ['persistent_id ' ],
222
+ 'retryInterval ' => $ params ['retry_interval ' ],
223
+ 'readTimeout ' => $ params ['read_timeout ' ],
224
+ ];
225
+
226
+ if ($ passAuth ) {
227
+ $ options ['auth ' ] = $ params ['auth ' ];
228
+ }
229
+
230
+ $ sentinel = new \RedisSentinel ($ options );
231
+ } else {
232
+ $ extra = $ passAuth ? [$ params ['auth ' ]] : [];
233
+
234
+ $ sentinel = new \RedisSentinel ($ host , $ port , $ params ['timeout ' ], (string ) $ params ['persistent_id ' ], $ params ['retry_interval ' ], $ params ['read_timeout ' ], ...$ extra );
217
235
}
218
- $ sentinel = new \RedisSentinel ($ host , $ port , $ params ['timeout ' ], (string ) $ params ['persistent_id ' ], $ params ['retry_interval ' ], $ params ['read_timeout ' ], ...$ extra );
219
236
220
237
try {
221
238
if ($ address = $ sentinel ->getMasterAddrByName ($ params ['redis_sentinel ' ])) {
0 commit comments