From aca22c8de444daf34a2ad7074d8688a88a3ea858 Mon Sep 17 00:00:00 2001 From: EarthlingDavey <15802017+EarthlingDavey@users.noreply.github.com> Date: Thu, 24 Oct 2024 17:16:49 +0100 Subject: [PATCH 1/2] Skip Redis object cache for auth endpoints. --- public/app/object-cache.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/public/app/object-cache.php b/public/app/object-cache.php index 2740e7df8..6b0d041cc 100644 --- a/public/app/object-cache.php +++ b/public/app/object-cache.php @@ -15,9 +15,13 @@ define( 'WP_REDIS_USE_RELAY', false ); } +// * There is a bug where auth transients are not being `set` or `get` correctly. +// It could be because auth endpoints `die()` early. So let's, skip the cache for auth endpoints. +$is_auth_url = strpos($_SERVER['REQUEST_URI'], '/auth/') === 0; + // * // 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 ( !$is_auth_url && 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', '' ); From 3623ec3883faa37d6b7b924c9118d8df4d5e34fa Mon Sep 17 00:00:00 2001 From: EarthlingDavey <15802017+EarthlingDavey@users.noreply.github.com> Date: Thu, 24 Oct 2024 17:17:44 +0100 Subject: [PATCH 2/2] Update object-cache.php --- public/app/object-cache.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/app/object-cache.php b/public/app/object-cache.php index 6b0d041cc..96e127081 100644 --- a/public/app/object-cache.php +++ b/public/app/object-cache.php @@ -17,11 +17,11 @@ // * There is a bug where auth transients are not being `set` or `get` correctly. // It could be because auth endpoints `die()` early. So let's, skip the cache for auth endpoints. -$is_auth_url = strpos($_SERVER['REQUEST_URI'], '/auth/') === 0; +$is_auth_uri = strpos($_SERVER['REQUEST_URI'], '/auth/') === 0; // * // Conditionally, run the script if the correct class exists, and the script has not been disabled. -if ( !$is_auth_url && class_exists( WP_REDIS_USE_RELAY ? 'Relay\Relay' : 'Redis' ) && ( ! defined( 'WP_REDIS_DISABLED' ) || ! WP_REDIS_DISABLED ) ): +if ( !$is_auth_uri && 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', '' );