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

Add Username, Password, Database and Unix Socket support. #352

Merged
merged 12 commits into from
Dec 18, 2024

Conversation

Vedant-Gandhi
Copy link
Contributor

Description

The aim of this PR is to add support for including the Username, Password, Database and Unix Socket Path for Redis.

Type

  • New Feature

Reference Issue

Screenshots

Screenshot 2024-09-06 at 12 20 46

Testing

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

@Vedant-Gandhi Vedant-Gandhi marked this pull request as ready for review September 6, 2024 07:01
@Vedant-Gandhi Vedant-Gandhi requested a review from SH4LIN October 10, 2024 06:16
Comment on lines 279 to 282
'redis_unix_socket' => '',
'redis_database' => 0,
'redis_username' => '',
'redis_password' => '',
Copy link

Choose a reason for hiding this comment

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

Fix the indentation

$data['redis_hostname'] = RT_WP_NGINX_HELPER_REDIS_HOSTNAME;
$data['redis_port'] = RT_WP_NGINX_HELPER_REDIS_PORT;
$data['redis_prefix'] = RT_WP_NGINX_HELPER_REDIS_PREFIX;
$data['redis_database'] = defined('RT_WP_NGINX_HELPER_REDIS_DATABASE') ? RT_WP_NGINX_HELPER_REDIS_DATABASE : 0;
Copy link

Choose a reason for hiding this comment

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

Fix indentation


$hostname = empty( $nginx_helper_admin->options['redis_unix_socket'] ) ? $nginx_helper_admin->options['redis_hostname'] : $nginx_helper_admin->options['redis_unix_socket'];
$port = empty( $nginx_helper_admin->options['redis_unix_socket'] ) ? $nginx_helper_admin->options['redis_port'] : 0;

$this->redis_object->connect(
Copy link

Choose a reason for hiding this comment

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

On my local setup, there’s no Nginx server or Redis installed. When I switch branches from master to your branch, the code throws a fatal error. The plugin is trying to connect, but the connection is being refused. If the plugin is attempting to make a connection, there should also be a fatal error in the master branch.

Please take a look into this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@SH4LIN I am unable to replicate the issue on my end. Can you please share the error here if possible?

Copy link

Choose a reason for hiding this comment

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

Sure.

Copy link

Choose a reason for hiding this comment

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

We are throwing a fatal error when the Redis connection is refused, which is understandable. However, this makes the entire admin side inaccessible. As a result, there is no way to update the connection configuration except by manually updating the value in the database or using WP-CLI.

One solution is to wrap the $this->redis_object->connect inside try catch and on the catch display WP notice

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@SH4LIN I found where the issue was and have fixed it. In predis it does not have checks for connection and instead immeditely executes the statement without checking if a connection is already established or not.

So in class-predis.php where we have addded selecting the databse feature, it was selecting the database without checking for connection establishment causing it to throw error.

@@ -22,6 +22,12 @@
'redis_hostname',
'redis_port',
'redis_prefix',
'redis_database',
Copy link

Choose a reason for hiding this comment

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

Fix the indentation

</td>
</tr>
<tr>
Copy link

Choose a reason for hiding this comment

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

Fix the indentation and use tabs instead of the space

@SH4LIN
Copy link

SH4LIN commented Dec 17, 2024

@Vedant-Gandhi Is this ready for review?

@Vedant-Gandhi Vedant-Gandhi requested a review from SH4LIN December 17, 2024 11:24
@Vedant-Gandhi
Copy link
Contributor Author

@SH4LIN Yes

@Vedant-Gandhi Vedant-Gandhi merged commit 51364b5 into develop Dec 18, 2024
1 of 2 checks passed
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