Created
March 15, 2022 08:47
-
-
Save richsage/219a00f1618214c5904c8e225b14f40e to your computer and use it in GitHub Desktop.
Moodle Redis TLS support
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected function new_redis($server, $prefix = '', $password = '') { | |
$redis = new Redis(); | |
// Check if it isn't a Unix socket to set default port. | |
$port = ($server[0] === '/') ? null : 6379; | |
// NOTE: This is the change we added | |
// You can supply eg tls://my.redis.host:6380/ for it to work | |
// Check for any protocol requirements eg TLS that have been specified. | |
if (strpos($server, ':')) { | |
$serverconf = parse_url($server); | |
$port = $serverconf['port'] ?? $port; | |
$scheme = $serverconf['scheme'] ?? ''; | |
$host = $serverconf['host'] ?? ''; | |
$server = (strlen($scheme) ? $scheme . '://' : ''); | |
$server .= $host; | |
} | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment