Skip to content
Snippets Groups Projects
Commit 999f7c41 authored by Erick Hitter's avatar Erick Hitter
Browse files

Since admin requests aren't routed through the cache frontend, the global...

Since admin requests aren't routed through the cache frontend, the global variable isn't available. Use defines for these overrides instead.

Unfortunately does mean that settings are split, but alternatives weren't appealing:
* store settings into an option via the front-end proxy (front-end writes are bad)
* store in Redis (could lose the option, randomly revealing a UI)
* pass all wp-admin requests through the proxy with early bailing to avoid breakage seems overly complicated and fragile/prone to bugs.
parent 585d31c4
No related branches found
No related tags found
No related merge requests found
...@@ -123,7 +123,7 @@ class WP_Redis_Cache { ...@@ -123,7 +123,7 @@ class WP_Redis_Cache {
private $ns = 'wp-redis-cache'; private $ns = 'wp-redis-cache';
/** /**
* * Singleton instantiation
*/ */
public static function get_instance() { public static function get_instance() {
if ( ! is_a( self::$__instance, __CLASS__ ) ) { if ( ! is_a( self::$__instance, __CLASS__ ) ) {
...@@ -161,12 +161,9 @@ class WP_Redis_Cache { ...@@ -161,12 +161,9 @@ class WP_Redis_Cache {
* @return null * @return null
*/ */
public function register_ui() { public function register_ui() {
// If cache life is set globally, don't show the UI // Don't show UI
global $wp_redis_cache_config; if ( defined( 'WP_REDIS_CACHE_HIDE_UI' ) && WP_REDIS_CACHE_HIDE_UI ) {
if ( is_array( $wp_redis_cache_config ) && return
( isset( $wp_redis_cache_config['cache_duration' ] ) || isset( $wp_redis_cache_config['unlimited' ] ) )
) {
return;
} }
add_options_page( 'WP Redis Cache', 'WP Redis Cache', 'manage_options', $this->ns, array( $this, 'render_ui' ) ); add_options_page( 'WP Redis Cache', 'WP Redis Cache', 'manage_options', $this->ns, array( $this, 'render_ui' ) );
...@@ -232,10 +229,14 @@ class WP_Redis_Cache { ...@@ -232,10 +229,14 @@ class WP_Redis_Cache {
); );
// Override default connection settings with global values, when present // Override default connection settings with global values, when present
global $wp_redis_cache_config; if ( defined( 'WP_REDIS_CACHE_REDIS_HOST' ) ) {
if ( is_array( $wp_redis_cache_config ) ) { $redis_settings['host'] = WP_REDIS_CACHE_REDIS_HOST;
$_redis_settings = array_intersect( $wp_redis_cache_config, $redis_settings ); }
$redis_settings = wp_parse_args( $_redis_settings, $redis_settings ); if ( defined( 'WP_REDIS_CACHE_REDIS_PORT' ) ) {
$redis_settings['port'] = WP_REDIS_CACHE_REDIS_PORT;
}
if ( defined( 'WP_REDIS_CACHE_REDIS_DB' ) ) {
$redis_settings['database'] = WP_REDIS_CACHE_REDIS_DB;
} }
$permalink = get_permalink( $post->ID ); $permalink = get_permalink( $post->ID );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment