Skip to content

Commit 5af0f99

Browse files
Exit the script early if the class doesn't exist, or it's been manually disabled.
1 parent 95c727c commit 5af0f99

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

object-cache.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
* can use this to guarantee uniqueness for the keys generated by this object cache.
88
*/
99

10+
if ( ! defined( 'WP_REDIS_USE_RELAY' ) ) {
11+
define( 'WP_REDIS_USE_RELAY', false );
12+
}
13+
14+
// Conditionally run the script if: the correct class exists, and the script has not been disabled.
15+
if ( class_exists( WP_REDIS_USE_RELAY ? 'Relay\Relay' : 'Redis' ) && ( ! defined( 'WP_REDIS_DISABLED' ) || ! WP_REDIS_DISABLED ) ):
16+
1017
if ( ! defined( 'WP_CACHE_KEY_SALT' ) ) {
1118
define( 'WP_CACHE_KEY_SALT', '' );
1219
}
@@ -1293,7 +1300,7 @@ public function build_client_parameters( $redis_server ) {
12931300
* @return Redis Redis client.
12941301
*/
12951302
public function prepare_client_connection( $client_parameters ) {
1296-
if ( defined( 'WP_REDIS_USE_RELAY' ) && WP_REDIS_USE_RELAY ) {
1303+
if ( WP_REDIS_USE_RELAY ) {
12971304
$redis = new Relay\Relay();
12981305
} else {
12991306
$redis = new Redis();

0 commit comments

Comments
 (0)