-
Notifications
You must be signed in to change notification settings - Fork 35
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
Fixed path of the cache libs #69
Conversation
WalkthroughThe changes in this pull request include modifications to the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (3)
rootfs/var/www/html/admin/cli/configure_redis.php (3)
Line range hint
25-32
: Consider enhancing Redis connectivity validationThe current connection check could be improved for better reliability and flexibility:
- Make the Redis port configurable via CLI argument
- Implement a more thorough connection test using the Redis protocol
- Add more detailed error reporting
Here's a suggested improvement:
- $fp = fsockopen($redis_server, 6379, $errno, $errstr, 5); // 5-second timeout - if (!$fp) { - echo "Unable to connect to Redis at $redis_server:6379. Error: $errstr ($errno)\n"; - exit; - } - fclose($fp); + // Ensure the REDIS_PORT parameter is provided (optional) + $redis_port = isset($argv[2]) ? (int)$argv[2] : 6379; + + try { + $redis = new Redis(); + if (!$redis->connect($redis_server, $redis_port, 5)) { + throw new Exception("Connection failed"); + } + if (!$redis->ping()) { + throw new Exception("PING failed"); + } + echo "Successfully connected to Redis at $redis_server:$redis_port\n"; + } catch (Exception $e) { + echo "Redis connection error: {$e->getMessage()}\n"; + echo "Please ensure Redis is running and accessible.\n"; + exit(1); + }
Line range hint
51-55
: Consider making the serializer configuration more flexibleThe serializer is hardcoded to igbinary (2). While this is generally a good choice for performance, it might not be available in all environments.
Consider adding a fallback:
$configuration = array( 'server' => $redis_server, 'port' => 6379, - 'serializer' => 2, // The faster igbinary serializer + 'serializer' => extension_loaded('igbinary') ? 2 : 1, // Use igbinary if available, else PHP serializer );
Line range hint
1-75
: Consider implementing idempotency for better reliabilityWhile the script works well, it could benefit from being more idempotent. Currently, it exits if the configuration exists but doesn't verify if the existing configuration matches the desired state.
Consider adding these improvements:
- Add a --force flag to override existing configurations
- Verify and update existing configurations if they don't match desired settings
- Add a dry-run mode to show what changes would be made
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (4)
.gitignore
(1 hunks)docker-compose.yml
(0 hunks)rootfs/var/www/html/admin/cli/configure_redis.php
(1 hunks)rootfs/var/www/html/admin/cli/install_plugin.php
(0 hunks)
💤 Files with no reviewable changes (2)
- docker-compose.yml
- rootfs/var/www/html/admin/cli/install_plugin.php
✅ Files skipped from review due to trivial changes (1)
- .gitignore
🔇 Additional comments (2)
rootfs/var/www/html/admin/cli/configure_redis.php (2)
Line range hint 58-75
: LGTM! Well-structured error handling and mode mapping
The implementation shows good practices:
- Proper use of try-catch for error handling
- Clear mode mappings for different cache types
- Informative feedback using mtrace()
44-44
: Verify the cache configuration class dependency
The change from locallib.php
to config_writer.php
appears to be correct as it uses the more specific class for cache configuration. However, let's verify this change across the Moodle codebase.
✅ Verification successful
Let me gather more information to verify this change thoroughly.
Let me try one final verification to check the cache configuration implementation.
Change from locallib.php to config_writer.php appears to be an isolated improvement
Based on the verification results, this change appears to be an isolated improvement in the Redis configuration script. The new approach using config_writer.php
is only used in this file, and there are no other references to the old locallib.php
approach in the codebase. This suggests the change is a targeted enhancement specific to this Redis configuration script.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify the usage of cache configuration classes in Moodle
# Check for other files using locallib.php for cache configuration
rg -l "require.*cache/locallib.php"
# Check for other files using the new approach
rg -l "require.*cache/classes/config_writer.php"
Length of output: 138
Script:
#!/bin/bash
# Check for any other cache configuration related files and their dependencies
rg -l "class.*config_writer"
# Check for any direct usage of cache locallib.php
ast-grep --pattern 'require_once($$$."cache/locallib.php")'
# Look for cache configuration related classes
fd -e php -x grep -l "cache.*config" {}
Length of output: 238
Script:
#!/bin/bash
# Check the content of config_writer.php to verify it's the correct dependency
fd -g "config_writer.php" -x cat {}
# Look for any cache configuration related classes in the codebase
rg -l "class.*cache.*config"
# Check for any references to the old locallib.php approach
rg -l "cache/locallib"
Length of output: 91
This pull request includes a modification in a PHP file related to configuring Redis. The most important changes is the update to the Redis configuration script.
Updates to Redis Configuration:
rootfs/var/www/html/admin/cli/configure_redis.php
: Changed the included cache library fromlocallib.php
toconfig_writer.php
to presumably use a more appropriate or updated class for cache configuration.Thanks to @huulbaek for reporting it!
Summary by CodeRabbit
Chores
.gitignore
to include.env
files.docker-compose.yml
configuration.install_plugin.php
script, which managed plugin installations via CLI.Refactor
configure_redis.php
by adopting a structured approach for cache store management.