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

Fatal Error on Empty Redis Port Setting in Nginx Helper Plugin #333

Closed
gagan0123 opened this issue Apr 12, 2024 · 1 comment
Closed

Fatal Error on Empty Redis Port Setting in Nginx Helper Plugin #333

gagan0123 opened this issue Apr 12, 2024 · 1 comment
Assignees
Labels

Comments

@gagan0123
Copy link
Member

Describe the bug
In the Nginx Helper plugin, enabling purge with "Redis Cache" as the "Caching Method" and saving the Redis settings with an empty port leads to a site crash. Any attempts to save settings or initiate a purge thereafter cause a fatal PHP error due to a type mismatch in the port argument.

To Reproduce
Steps to reproduce the behavior:

  1. Go to the Nginx Helper plugin settings.
  2. Enable purge and select "Redis Cache" as the "Caching Method".
  3. Save the Redis settings with the port field empty.
  4. Try saving any subsequent settings or perform a purge.
  5. Observe that the site becomes inaccessible and a PHP fatal error occurs.

NOTE: The error only occurs if the redis module is enabled in PHP; otherwise, the code never reaches the PhpRedis_Purger constructor

Expected behavior
The expected behavior of the plugin is that it should handle an empty port setting gracefully. Either by validating the input to ensure it's a number or by defaulting to a standard port when none is provided, thus preventing the site from crashing.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
The error reported is:

PHP Fatal error: Uncaught TypeError: Redis::connect(): Argument #2 ($port) must be of type int, string given in /app/wordpress/wp-content/plugins/nginx-helper/admin/class-phpredis-purger.php:45

This suggests that there's a type-check issue in the code handling the Redis port settings, which could be mitigated by additional input validation or setting default values.

@gagan0123 gagan0123 added the bug label Apr 12, 2024
Pathan-Amaankhan added a commit that referenced this issue Apr 15, 2024
GH-333: Fatal Error on Empty Redis Port Setting in Nginx Helper Plugin [Develop]
Pathan-Amaankhan added a commit that referenced this issue Apr 15, 2024
GH-333: Fatal Error on Empty Redis Port Setting in Nginx Helper Plugin [Master]
@gagan0123
Copy link
Member Author

Fixed in version 2.2.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants