Plugin Directory


Ignore:
Timestamp:
10/12/2026 08:01:29 AM (4 weeks ago)
Author:
wpdevteam
Message:

Update to version 1.4.2 from GitHub

File:
1 edited

Legend:

Unmodified
Added
Removed
  • xspeed/trunk/includes/object-cache.php

    r3693847 r3740781  
    6969                        'host'     => $is_memcached
    7070                                ? 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' ),
    7272                        'port'     => $is_memcached
    7373                                ? array( 'XSPEED_OC_MC_PORT', 'XSPEED_OC_PORT' )
    … …  
    7676                        // form it carries the ACL username too, so a site that defines only
    7777                        // 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' ),
    7979                        'password' => array( 'XSPEED_OC_PASSWORD', 'WP_REDIS_PASSWORD' ),
    8080                        'database' => array( 'XSPEED_OC_DATABASE', 'WP_REDIS_DATABASE' ),
    … …  
    184184                                        continue;
    185185                                }
     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                                }
    186192                                $value = constant( $const );
    187193                                // WP_REDIS_PASSWORD only answers for `user` in its array form,
    … …  
    275281                }
    276282                return array( $entry, null );
     283        }
     284}
     285
     286if ( ! 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 : '';
    277306        }
    278307}
    … …  
    702731
    703732                                        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)
    705736                                                $this->client = 'phpredis';
    706737                                                $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
    708744                                                        ? @$redis->pconnect( $host, $port, $timeout )
    709745                                                        : @$redis->connect( $host, $port, $timeout );
Note: See TracChangeset for help on using the changeset viewer.