Changeset 3740781 for xspeed/trunk/includes/object-cache.php
- Timestamp:
- 10/12/2026 08:01:29 AM (4 weeks ago)
- File:
-
- 1 edited
-
xspeed/trunk/includes/object-cache.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
xspeed/trunk/includes/object-cache.php
r3693847 r3740781 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' ) … … 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' ), … … 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, … … 275 281 } 276 282 return array( $entry, null ); 283 } 284 } 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 : ''; 277 306 } 278 307 } … … 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 );
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)