diff --git a/composer.json b/composer.json index b75d39e15..7355e33c9 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ }, "require-dev": { "phpunit/phpunit": "^7.5", - "swoft/swoole-ide-helper": "dev-master" + "swoole/ide-helper": "dev-master" }, "replace": { "swoft/annotation": "self.version", diff --git a/src/http-server/test/testing/MockResponse.php b/src/http-server/test/testing/MockResponse.php index 3a3c1eab5..0983cb97f 100644 --- a/src/http-server/test/testing/MockResponse.php +++ b/src/http-server/test/testing/MockResponse.php @@ -80,14 +80,15 @@ public function header($key, $value, $ucwords = null) } /** - * @param string $name - * @param string $value - * @param int|string $expires - * @param string|null $path - * @param string $domain - * @param bool $secure - * @param bool $httpOnly - * @param null $samesite + * @param string $name + * @param string|null $value + * @param int|string|null $expires + * @param string|null $path + * @param string|null $domain + * @param bool|null $secure + * @param bool|null $httpOnly + * @param string|null $samesite + * @param string|null $priority */ public function cookie( $name, @@ -97,7 +98,8 @@ public function cookie( $domain = null, $secure = null, $httpOnly = null, - $samesite = null + $samesite = null, + $priority = null ) { $result = \urlencode($name) . '=' . \urlencode($value); @@ -117,22 +119,26 @@ public function cookie( } if ($timestamp !== 0) { - $result .= '; expires=' . \gmdate('D, d-M-Y H:i:s e', $timestamp); + $result .= '; Expires=' . \gmdate('D, d-M-Y H:i:s e', $timestamp); } } if ($secure) { - $result .= '; secure'; + $result .= '; Secure'; } - // if ($hostOnly) { - // $result .= '; HostOnly'; - // } - if ($httpOnly) { $result .= '; HttpOnly'; } + if ($samesite) { + $result .= '; SameSite=' . $samesite; + } + + if ($priority) { + $result .= '; Priority=' . $priority; + } + $this->cookie[$name] = $result; } diff --git a/src/redis/src/Connector/PhpRedisConnector.php b/src/redis/src/Connector/PhpRedisConnector.php index 9bcd424c1..0433979dd 100644 --- a/src/redis/src/Connector/PhpRedisConnector.php +++ b/src/redis/src/Connector/PhpRedisConnector.php @@ -11,6 +11,7 @@ use Swoft\Redis\Exception\RedisException; use Swoft\Stdlib\Helper\Arr; use Swoft\Stdlib\Helper\JsonHelper; +use function version_compare; /** * Class PhpRedisConnector @@ -30,6 +31,11 @@ class PhpRedisConnector implements ConnectorInterface */ public function connect(array $config, array $option): Redis { + if (isset($option['auth'])) { + $config['auth'] = $option['auth']; + unset($option['auth']); + } + $client = new Redis(); $this->establishConnection($client, $config); @@ -159,12 +165,17 @@ protected function establishConnection(Redis $client, array $config): void $config['host'], $config['port'], $config['timeout'], - '', + null, $config['retry_interval'], ]; - if (version_compare(phpversion('redis'), '3.1.3', '>=')) { + $redisVersion = \phpversion('redis'); + if (\version_compare($redisVersion, '3.1.3', '>=')) { $parameters[] = $config['read_timeout']; + + if (!empty($config['auth']) && \version_compare($redisVersion, '3.5', '>=')) { + $parameters[] = ['auth' => $config['auth']]; + } } $result = $client->connect(...$parameters);