Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Predis Exception when Database is Out of Bounds. #376

Merged
merged 5 commits into from
Dec 23, 2024

Conversation

Vedant-Gandhi
Copy link
Contributor

Description

The aim of this PR is to handle the exception when the database number for Predis is out of bounds.

Type

  • Bug Fix

Reference Issue

Testing

The code has been tested locally and is working as expected.

Copy link
Member

@Pathan-Amaankhan Pathan-Amaankhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving with minor changes. Please test the change locally before merging.

@@ -60,14 +60,16 @@ public function __construct() {

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

if( $nginx_helper_admin->options['redis_database'] !== 0 ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if( $nginx_helper_admin->options['redis_database'] !== 0 ) {
if( 0 !== $nginx_helper_admin->options['redis_database'] ) {

@@ -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'] ) ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if( !empty( $nginx_helper_admin->options['redis_unix_socket'] ) ) {
if( ! empty( $nginx_helper_admin->options['redis_unix_socket'] ) ) {

@@ -60,14 +60,16 @@ public function __construct() {

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->redis_object->select($nginx_helper_admin->options['redis_database']);
$this->redis_object->select( $nginx_helper_admin->options['redis_database'] );

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove additional new line.

@Vedant-Gandhi Vedant-Gandhi merged commit 5854fd9 into develop Dec 23, 2024
1 of 3 checks passed
@Vedant-Gandhi Vedant-Gandhi deleted the fix/redis-db-oob-crash branch December 23, 2024 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants