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

Exit the script early if the class doesn't exist, or it's been manually disabled. #468

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion object-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
* can use this to guarantee uniqueness for the keys generated by this object cache.
*/

if ( ! defined( 'WP_REDIS_USE_RELAY' ) ) {
define( 'WP_REDIS_USE_RELAY', false );
}

// Conditionally run the script if: the correct class exists, and the script has not been disabled.
if ( class_exists( WP_REDIS_USE_RELAY ? 'Relay\Relay' : 'Redis' ) && ( ! defined( 'WP_REDIS_DISABLED' ) || ! WP_REDIS_DISABLED ) ):

if ( ! defined( 'WP_CACHE_KEY_SALT' ) ) {
define( 'WP_CACHE_KEY_SALT', '' );
}
Expand Down Expand Up @@ -1293,7 +1300,7 @@ public function build_client_parameters( $redis_server ) {
* @return Redis Redis client.
*/
public function prepare_client_connection( $client_parameters ) {
if ( defined( 'WP_REDIS_USE_RELAY' ) && WP_REDIS_USE_RELAY ) {
if ( WP_REDIS_USE_RELAY ) {
$redis = new Relay\Relay();
} else {
$redis = new Redis();
Expand Down