Skip to content

Commit

Permalink
Merge pull request #377 from rtCamp/fix/redis-db-oob-crash
Browse files Browse the repository at this point in the history
Handle Predis Exception when Database is Out of Bounds.
  • Loading branch information
Vedant-Gandhi authored Dec 23, 2024
2 parents 6946181 + 1dd31f2 commit de9b5e0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions admin/class-predis-purger.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct() {
$username = $nginx_helper_admin->options['redis_username'];
$password = $nginx_helper_admin->options['redis_password'];

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

try {
$this->redis_object->connect();

if( 0 !== $nginx_helper_admin->options['redis_database'] ) {
$this->redis_object->select( $nginx_helper_admin->options['redis_database'] );
}
} catch ( Exception $e ) {
$this->log( $e->getMessage(), 'ERROR' );
return;
}

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

}

Expand Down

0 comments on commit de9b5e0

Please sign in to comment.