PluginProbe
xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN / 1.4.2
xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN v1.4.2
1.4.2 1.4.1 1.4.0 1.3.7 1.3.6 1.3.5 1.3.4 1.3.3 1.3.2 1.3.1 1.3.0 1.2.4 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 All 36 releases
← All changes | includes/object-cache.php +40 -4 1.3.3 → 1.4.2 View file →
@@ -67,9 +67,9 @@
67 67 // 127.0.0.1 on upgrade -- breaking a working cache. New writes use
68 68 // XSPEED_OC_MC_*, so the fallback fades out on the next save.
69 69 'host' => $is_memcached
70 70 ? array( 'XSPEED_OC_MC_HOST', 'XSPEED_OC_HOST' )
71 - : array( 'XSPEED_OC_HOST', 'WP_REDIS_HOST' ),
71 + : array( 'XSPEED_OC_HOST', 'WP_REDIS_PATH', 'WP_REDIS_HOST' ),
72 72 'port' => $is_memcached
73 73 ? array( 'XSPEED_OC_MC_PORT', 'XSPEED_OC_PORT' )
74 74 : array( 'XSPEED_OC_PORT', 'WP_REDIS_PORT' ),
75 75 // WP_REDIS_PASSWORD trails the user names on purpose: in its array
@@ -74,9 +74,9 @@
74 74 : array( 'XSPEED_OC_PORT', 'WP_REDIS_PORT' ),
75 75 // WP_REDIS_PASSWORD trails the user names on purpose: in its array
76 76 // form it carries the ACL username too, so a site that defines only
77 77 // the password pair still authenticates as the right user.
78 - 'user' => array( 'XSPEED_OC_USER', 'WP_REDIS_USER', 'WP_REDIS_PASSWORD' ),
78 + 'user' => array( 'XSPEED_OC_USER', 'WP_REDIS_USERNAME', 'WP_REDIS_USER', 'WP_REDIS_PASSWORD' ),
79 79 'password' => array( 'XSPEED_OC_PASSWORD', 'WP_REDIS_PASSWORD' ),
80 80 'database' => array( 'XSPEED_OC_DATABASE', 'WP_REDIS_DATABASE' ),
81 81 'timeout' => array( 'XSPEED_OC_TIMEOUT', 'WP_REDIS_TIMEOUT' ),
82 82 'salt' => array( 'XSPEED_OC_SALT', 'WP_REDIS_PREFIX', 'WP_CACHE_KEY_SALT' ),
@@ -182,8 +182,14 @@
182 182 foreach ( $sorted as $const ) {
183 183 if ( ! defined( $const ) ) {
184 184 continue;
185 185 }
186 + // WP_REDIS_PATH names a socket only when WP_REDIS_SCHEME is
187 + // `unix` in any case, the same gate the schema declares in
188 + // `constants_when`. Redis Object Cache uses strcasecmp(). (#566)
189 + if ( 'WP_REDIS_PATH' === $const && ! ( defined( 'WP_REDIS_SCHEME' ) && is_string( constant( 'WP_REDIS_SCHEME' ) ) && 0 === strcasecmp( constant( 'WP_REDIS_SCHEME' ), 'unix' ) ) ) {
190 + continue;
191 + }
186 192 $value = constant( $const );
187 193 // WP_REDIS_PASSWORD only answers for `user` in its array form,
188 194 // which carries the ACL username. As a plain string it is just
189 195 // a password: skip it, or we would authenticate with the
@@ -276,8 +282,31 @@
276 282 return array( $entry, null );
277 283 }
278 284 }
279 285
286 +if ( ! function_exists( 'xspeed_oc_redis_socket' ) ) {
287 + /**
288 + * The unix socket path a Redis host names, or '' for a network host.
289 + *
290 + * A copy of \XSpeed\Redis_Client::socket_path(), which this drop-in cannot
291 + * call when phpredis is the client: the class is only loaded for the
292 + * built-in one. ObjectCacheSocketTest runs both over the same inputs, so
293 + * the panel's Test connection and the runtime agree on what a socket is.
294 + * (#566)
295 + *
296 + * @param string $host Configured Redis host.
297 + * @return string Socket path, or ''.
298 + */
299 + function xspeed_oc_redis_socket( $host ) {
300 + $host = trim( (string) $host );
301 + if ( 0 === stripos( $host, 'unix:' ) ) {
302 + // unix:///path and unix:/path both name /path.
303 + $host = '/' . ltrim( substr( $host, 5 ), '/' );
304 + }
305 + return ( '' !== $host && '/' === $host[0] && '/' !== $host ) ? $host : '';
306 + }
307 +}
308 +
280 309 if ( ! function_exists( 'xspeed_oc_our_constants' ) ) {
281 310 /**
282 311 * Constant names defined inside OUR fenced block in wp-config.php.
283 312 *
@@ -700,12 +729,19 @@
700 729 $db = (int) xspeed_oc_config( 'database', 0 );
701 730 $persist = (bool) xspeed_oc_config( 'persist', false );
702 731
703 732 if ( class_exists( 'Redis' ) ) {
704 - // phpredis extension (preferred).
733 + // phpredis extension (preferred). It opens a unix
734 + // socket only for a bare path with a port below 1;
735 + // with any real port it tries TCP to the path. (#566)
705 736 $this->client = 'phpredis';
706 737 $redis = new Redis();
707 - $ok = $persist
738 + $socket = xspeed_oc_redis_socket( $host );
739 + if ( '' !== $socket ) {
740 + $host = $socket;
741 + $port = 0;
742 + }
743 + $ok = $persist
708 744 ? @$redis->pconnect( $host, $port, $timeout )
709 745 : @$redis->connect( $host, $port, $timeout );
710 746 if ( $ok ) {
711 747 // Redis 6+ ACL: ['user'=>..,'pass'=>..] when a username