Skip to content

Commit de9b5e0

Browse files
Merge pull request #377 from rtCamp/fix/redis-db-oob-crash
Handle Predis Exception when Database is Out of Bounds.
2 parents 6946181 + 1dd31f2 commit de9b5e0

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

admin/class-predis-purger.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct() {
4343
$username = $nginx_helper_admin->options['redis_username'];
4444
$password = $nginx_helper_admin->options['redis_password'];
4545

46-
if( empty( $nginx_helper_admin->options['redis_unix_socket'] ) ) {
46+
if( ! empty( $nginx_helper_admin->options['redis_unix_socket'] ) ) {
4747
$predis_args['path'] = $nginx_helper_admin->options['redis_unix_socket'];
4848
} else {
4949
$predis_args['host'] = $nginx_helper_admin->options['redis_hostname'];;
@@ -60,14 +60,15 @@ public function __construct() {
6060

6161
try {
6262
$this->redis_object->connect();
63+
64+
if( 0 !== $nginx_helper_admin->options['redis_database'] ) {
65+
$this->redis_object->select( $nginx_helper_admin->options['redis_database'] );
66+
}
6367
} catch ( Exception $e ) {
6468
$this->log( $e->getMessage(), 'ERROR' );
6569
return;
6670
}
6771

68-
if( $nginx_helper_admin->options['redis_database'] !== 0 ) {
69-
$this->redis_object->select($nginx_helper_admin->options['redis_database']);
70-
}
7172

7273
}
7374

0 commit comments

Comments
 (0)