From 9c5a77d156fc670c25384d85f84d97977be6f56c Mon Sep 17 00:00:00 2001 From: Xon Date: Tue, 8 Mar 2022 07:54:44 +0800 Subject: [PATCH 1/6] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c82fb83..06082ab 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ vendor phpunit.phar phpunit_*.log +/.phpunit.result.cache From 49e1f7d66a6a835bc58b8b7e31898101b8051be9 Mon Sep 17 00:00:00 2001 From: Xon Date: Tue, 8 Mar 2022 08:10:59 +0800 Subject: [PATCH 2/6] This test doesn't actually do anything --- tests/CredisStandaloneTest.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/tests/CredisStandaloneTest.php b/tests/CredisStandaloneTest.php index f47514d..46f41ca 100644 --- a/tests/CredisStandaloneTest.php +++ b/tests/CredisStandaloneTest.php @@ -6,19 +6,6 @@ class CredisStandaloneTest extends CredisTest { protected $useStandalone = TRUE; - /** - * @group UnixSocket - */ - public function testInvalidPersistentConnectionOnUnixSocket() - { - $this->credis->close(); - $this->credis = new Credis_Client('unix://'.realpath(__DIR__).'/redis.sock',0,null,'persistent'); - $this->credis->forceStandalone(); - //$this->setExpectedException('CredisException','Persistent connections to UNIX sockets are not supported in standalone mode.'); - $this->credis->connect(); - $this->assertTrue($this->credis->isConnected()); - } - public function testPersistentConnectionsOnStandAloneTcpConnection() { $this->credis->close(); From 9182d889210dbfad2b1e6ef1b0d5e1e72cbe16bb Mon Sep 17 00:00:00 2001 From: Xon Date: Tue, 8 Mar 2022 08:12:32 +0800 Subject: [PATCH 3/6] Adjust socket tests to capture testing phpredis --- tests/CredisTest.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/CredisTest.php b/tests/CredisTest.php index c8fbdf3..3e1f392 100644 --- a/tests/CredisTest.php +++ b/tests/CredisTest.php @@ -679,11 +679,12 @@ public function testConnectionStringsTls() */ public function testConnectionStringsSocket() { - $this->credis = new Credis_Client(realpath(__DIR__).'/redis.sock',0,null,'persistent'); + $this->credis = new Credis_Client(realpath(__DIR__).'/redis.sock'); if ($this->useStandalone) { $this->credis->forceStandalone(); } $this->credis->connect(); + $this->assertTrue($this->credis->isConnected()); $this->credis->set('key','value'); $this->assertEquals('value',$this->credis->get('key')); } @@ -708,6 +709,9 @@ public function testInvalidTlsConnectionString() } } + /** + * @group UnixSocket + */ public function testInvalidUnixSocketConnectionString() { $this->credis->close(); From 1f759b06570095b397b8b17c0be85379b8867da4 Mon Sep 17 00:00:00 2001 From: Xon Date: Tue, 8 Mar 2022 07:51:35 +0800 Subject: [PATCH 4/6] phpredis connect's port is int and doesn't actually accept nulls, 0 is the documented value for unix connection strings, even for older versions --- Client.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Client.php b/Client.php index f4389df..72b209a 100755 --- a/Client.php +++ b/Client.php @@ -201,7 +201,7 @@ class Credis_Client { /** * Port on which the Redis server is running - * @var integer + * @var integer|null */ protected $port; @@ -358,7 +358,7 @@ public function getHost() } /** * Return the port of the Redis instance - * @return int + * @return int|null */ public function getPort() { @@ -474,8 +474,8 @@ public function connect() try { $result = $this->persistent - ? $this->redis->pconnect($this->host, $this->port, $socketTimeout, $this->persistent) - : $this->redis->connect($this->host, $this->port, $socketTimeout); + ? $this->redis->pconnect($this->host, (int)$this->port, $socketTimeout, $this->persistent) + : $this->redis->connect($this->host, (int)$this->port, $socketTimeout); } catch(Exception $e) { From b09b4ca44667d1a07c109b941f894cb4b0da6cb8 Mon Sep 17 00:00:00 2001 From: Xon Date: Tue, 8 Mar 2022 08:28:12 +0800 Subject: [PATCH 5/6] Add suggests statement to composer.json --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index 9223e13..9f69167 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,9 @@ "require": { "php": ">=5.4.0" }, + "suggest": { + "ext-redis": "Improved performance for communicating with redis" + }, "autoload": { "classmap": [ "Client.php", From c3622c13514b8af6ff20f356a53c43f2357d0286 Mon Sep 17 00:00:00 2001 From: Xon Date: Tue, 8 Mar 2022 08:29:03 +0800 Subject: [PATCH 6/6] Update minimum php version supported to 5.6 to match tests --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 9f69167..2b781e6 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ } ], "require": { - "php": ">=5.4.0" + "php": ">=5.6.0" }, "suggest": { "ext-redis": "Improved performance for communicating with redis"