From 7376902b201f380aadb32c6a89aa294aa20d6d7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Till=20Kru=CC=88ss?= Date: Fri, 14 Aug 2020 10:11:49 -0700 Subject: [PATCH 1/9] update org references --- CONTRIBUTING.md | 2 +- FAQ.md | 2 +- README.md | 16 ++++++++-------- composer.json | 4 ++-- tests/Predis/Collection/Iterator/HashKeyTest.php | 4 ++-- .../Collection/Iterator/SortedSetKeyTest.php | 2 +- .../Command/StringIncrementByFloatTest.php | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9ad2f5e3..3cf3c21b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ ## Filing bug reports ## -Bugs or feature requests can be posted on the [GitHub issues](http://github.com/predishq/predis/issues) +Bugs or feature requests can be posted on the [GitHub issues](http://github.com/predis/predis/issues) section of the project. When reporting bugs, in addition to the obvious description of your issue you __must__ always provide diff --git a/FAQ.md b/FAQ.md index 567f6b9e..152f534a 100644 --- a/FAQ.md +++ b/FAQ.md @@ -33,7 +33,7 @@ usually something that developers prefer to customize depending on their needs a generalized when using Redis because of the many possible access patterns for your data. This does not mean that it is impossible to have such a feature since you can leverage the extensibility of this library to define your own serialization-aware commands. You can find more details about how to -do that [on this issue](http://github.com/predishq/predis/issues/29#issuecomment-1202624). +do that [on this issue](http://github.com/predis/predis/issues/29#issuecomment-1202624). ### How can I force Predis to connect to Redis before sending any command? ### diff --git a/README.md b/README.md index 416fa234..315e0622 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ More details about this project can be found on the [frequently asked questions] This library can be found on [Packagist](http://packagist.org/packages/predis/predis) for an easier management of projects dependencies using [Composer](http://packagist.org/about-composer) or on our [own PEAR channel](http://pear.nrk.io) for a more traditional installation using PEAR. Ultimately, -compressed archives of each release are [available on GitHub](https://github.com/predishq/predis/releases). +compressed archives of each release are [available on GitHub](https://github.com/predis/predis/releases). ### Loading the library ### @@ -451,7 +451,7 @@ the development server profile will be used. You can refer to [the tests README] for more detailed information about testing Predis. Predis uses Travis CI for continuous integration and the history for past and current builds can be -found [on its project page](http://travis-ci.org/predishq/predis). +found [on its project page](http://travis-ci.org/predis/predis). ## Other ## @@ -459,9 +459,9 @@ found [on its project page](http://travis-ci.org/predishq/predis). ### Project related links ### -- [Source code](https://github.com/predishq/predis) -- [Wiki](https://github.com/predishq/predis/wiki) -- [Issue tracker](https://github.com/predishq/predis/issues) +- [Source code](https://github.com/predis/predis) +- [Wiki](https://github.com/predis/predis/wiki) +- [Issue tracker](https://github.com/predis/predis/issues) - [PEAR channel](http://pear.nrk.io) @@ -474,13 +474,13 @@ found [on its project page](http://travis-ci.org/predishq/predis). The code for Predis is distributed under the terms of the MIT license (see [LICENSE](LICENSE)). -[ico-license]: https://img.shields.io/github/license/predishq/predis.svg?style=flat-square +[ico-license]: https://img.shields.io/github/license/predis/predis.svg?style=flat-square [ico-version-stable]: https://img.shields.io/packagist/v/predis/predis.svg?style=flat-square [ico-version-dev]: https://img.shields.io/packagist/vpre/predis/predis.svg?style=flat-square [ico-downloads-monthly]: https://img.shields.io/packagist/dm/predis/predis.svg?style=flat-square -[ico-travis]: https://img.shields.io/travis/predishq/predis.svg?style=flat-square +[ico-travis]: https://img.shields.io/travis/predis/predis.svg?style=flat-square [ico-hhvm]: https://img.shields.io/hhvm/predis/predis.svg?style=flat-square [link-packagist]: https://packagist.org/packages/predis/predis -[link-travis]: https://travis-ci.org/predishq/predis +[link-travis]: https://travis-ci.org/predis/predis [link-downloads]: https://packagist.org/packages/predis/predis/stats diff --git a/composer.json b/composer.json index cd5d26c4..4d273062 100644 --- a/composer.json +++ b/composer.json @@ -3,10 +3,10 @@ "type": "library", "description": "Flexible and feature-complete Redis client for PHP and HHVM", "keywords": ["nosql", "redis", "predis"], - "homepage": "http://github.com/predishq/predis", + "homepage": "http://github.com/predis/predis", "license": "MIT", "support": { - "issues": "https://github.com/predishq/predis/issues" + "issues": "https://github.com/predis/predis/issues" }, "authors": [ { diff --git a/tests/Predis/Collection/Iterator/HashKeyTest.php b/tests/Predis/Collection/Iterator/HashKeyTest.php index d2901749..56088638 100644 --- a/tests/Predis/Collection/Iterator/HashKeyTest.php +++ b/tests/Predis/Collection/Iterator/HashKeyTest.php @@ -57,8 +57,8 @@ class HashKeyTest extends PredisTestCase } /** - * @see https://github.com/predishq/predis/pull/330 - * @see https://github.com/predishq/predis/issues/331 + * @see https://github.com/predis/predis/pull/330 + * @see https://github.com/predis/predis/issues/331 * @group disconnected */ public function testIterationWithIntegerFields() diff --git a/tests/Predis/Collection/Iterator/SortedSetKeyTest.php b/tests/Predis/Collection/Iterator/SortedSetKeyTest.php index aeadeb5f..5435e7db 100644 --- a/tests/Predis/Collection/Iterator/SortedSetKeyTest.php +++ b/tests/Predis/Collection/Iterator/SortedSetKeyTest.php @@ -57,7 +57,7 @@ class SortedSetKeyTest extends PredisTestCase } /** - * @see https://github.com/predishq/predis/issues/216 + * @see https://github.com/predis/predis/issues/216 * @group disconnected */ public function testIterationWithIntegerMembers() diff --git a/tests/Predis/Command/StringIncrementByFloatTest.php b/tests/Predis/Command/StringIncrementByFloatTest.php index 4976d1fc..796bcb8c 100644 --- a/tests/Predis/Command/StringIncrementByFloatTest.php +++ b/tests/Predis/Command/StringIncrementByFloatTest.php @@ -76,7 +76,7 @@ class StringIncrementByFloatTest extends PredisCommandTestCase $redis->set('foo', 2); // We use round() to avoid errors on some platforms, see the following - // issue https://github.com/predishq/predis/issues/220 for reference. + // issue https://github.com/predis/predis/issues/220 for reference. $this->assertEquals(22.123, $redis->incrbyfloat('foo', 20.123)); $this->assertEquals(10, round($redis->incrbyfloat('foo', -12.123), 5)); $this->assertEquals(-100.01, round($redis->incrbyfloat('foo', -110.01), 5)); From 748969030652e40d9fd10f59493f0624cea20162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Till=20Kru=CC=88ss?= Date: Tue, 18 Aug 2020 13:55:36 -0700 Subject: [PATCH 2/9] include patch files in exports just to be safe See #642 --- .gitattributes | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index ca9c9dab..34569e32 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,8 @@ * text=auto -/tests export-ignore +/tests/PHPUnit export-ignore +/tests/Predis export-ignore +/tests/bootstrap.php export-ignore /.editorconfig export-ignore /.gitattributes export-ignore /.gitignore export-ignore From 2ce537d75e610550f5337e41b2a971417999b028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Till=20Kru=CC=88ss?= Date: Tue, 18 Aug 2020 14:00:59 -0700 Subject: [PATCH 3/9] bump version to v1.1.3 --- CHANGELOG.md | 12 ++++++++++++ VERSION | 2 +- package.ini | 2 +- src/Client.php | 2 +- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae59606d..e8543146 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +v1.1.3 (2020-08-18) +================================================================================ + +- Ensure compatibility with PHP 8. + +- Moved repository from `github.com/nrk/predis` to `github.com/predis/predis`. + +- __FIX__: Moved `cweagans/composer-patches` dependency to `require-dev`. + +- __FIX__: Include PHPUnit `.patch` files in exports. + + v1.1.2 (2020-08-11) ================================================================================ diff --git a/VERSION b/VERSION index 45a1b3f4..781dcb07 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.2 +1.1.3 diff --git a/package.ini b/package.ini index 3ba810b6..447f4f69 100644 --- a/package.ini +++ b/package.ini @@ -10,7 +10,7 @@ name = "Predis" desc = "Flexible and feature-complete Redis client for PHP and HHVM" homepage = "http://github.com/nrk/predis" license = "MIT" -version = "1.1.2" +version = "1.1.3" stability = "stable" channel = "pear.nrk.io" diff --git a/src/Client.php b/src/Client.php index 4b210696..acfa077d 100644 --- a/src/Client.php +++ b/src/Client.php @@ -40,7 +40,7 @@ use Predis\Transaction\MultiExec as MultiExecTransaction; */ class Client implements ClientInterface, \IteratorAggregate { - const VERSION = '1.1.2'; + const VERSION = '1.1.3'; protected $connection; protected $options; From 4363345f7c2bb232558d80788264ed035d7867e9 Mon Sep 17 00:00:00 2001 From: Peter Gribanov Date: Mon, 25 Mar 2019 19:31:56 +0300 Subject: [PATCH 4/9] iterate not iterable connections #552 --- src/Client.php | 4 +++- tests/Predis/ClientTest.php | 12 +++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Client.php b/src/Client.php index ee272d9c..16f61c49 100644 --- a/src/Client.php +++ b/src/Client.php @@ -535,7 +535,9 @@ class Client implements ClientInterface, \IteratorAggregate $connection = $this->getConnection(); if (!$connection instanceof \Traversable) { - throw new ClientException('The underlying connection is not traversable'); + return new \ArrayIterator(array( + (string) $connection => new static($connection, $this->getOptions()) + )); } foreach ($connection as $node) { diff --git a/tests/Predis/ClientTest.php b/tests/Predis/ClientTest.php index 93ef909f..865a8657 100644 --- a/tests/Predis/ClientTest.php +++ b/tests/Predis/ClientTest.php @@ -853,15 +853,17 @@ class ClientTest extends PredisTestCase /** * @group disconnected - * @expectedException \Predis\ClientException - * @expectedExceptionMessage The underlying connection is not traversable */ - public function testGetIteratorWithNonTraversableConnectionThrowsException() + public function testGetIteratorWithNonTraversableConnectionNoException() { - $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); + $connection = $this->getMockConnection('tcp://127.0.0.1:6381'); $client = new Client($connection); - $client->getIterator(); + $iterator = $client->getIterator(); + + $this->assertInstanceOf('\Predis\Client', $nodeClient = $iterator->current()); + $this->assertSame($connection, $nodeClient->getConnection()); + $this->assertSame('127.0.0.1:6381', $iterator->key()); } // ******************************************************************** // From 0a6306b73ed403b04f0c87d498d764650b4645ea Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Sun, 23 Aug 2020 17:46:12 +0200 Subject: [PATCH 5/9] Back to development. --- VERSION | 2 +- package.ini | 2 +- src/Client.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index 781dcb07..738a8397 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.3 +1.1.4-dev diff --git a/package.ini b/package.ini index 447f4f69..9cacd749 100644 --- a/package.ini +++ b/package.ini @@ -10,7 +10,7 @@ name = "Predis" desc = "Flexible and feature-complete Redis client for PHP and HHVM" homepage = "http://github.com/nrk/predis" license = "MIT" -version = "1.1.3" +version = "1.1.4" stability = "stable" channel = "pear.nrk.io" diff --git a/src/Client.php b/src/Client.php index acfa077d..4ae0a094 100644 --- a/src/Client.php +++ b/src/Client.php @@ -40,7 +40,7 @@ use Predis\Transaction\MultiExec as MultiExecTransaction; */ class Client implements ClientInterface, \IteratorAggregate { - const VERSION = '1.1.3'; + const VERSION = '1.1.4-dev'; protected $connection; protected $options; From 71008842019dcc7f88090e23da676c9428d58ce8 Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Sun, 23 Aug 2020 17:48:38 +0200 Subject: [PATCH 6/9] Update CHANGELOG. --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8543146..64425506 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +v1.1.4 (2020-xx-xx) +================================================================================ + +- __FIX__: initializing an iteration over a client instance when it is connected + to a standalone Redis server will not throw an exception anymore, instead it + will return an iterator that will run for just one loop returning a new client + instance using the underlying single-node connection (ISSUE #552, PR #556). + + v1.1.3 (2020-08-18) ================================================================================ From 2440a61cba96f845e7e3db7739e638670552b69f Mon Sep 17 00:00:00 2001 From: GITSRC <34047788+gitsrc@users.noreply.github.com> Date: Wed, 9 Jan 2019 15:47:03 +0800 Subject: [PATCH 7/9] Fix HashRing to use method defined by HashGeneratorInterface. --- src/Cluster/Distributor/HashRing.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cluster/Distributor/HashRing.php b/src/Cluster/Distributor/HashRing.php index db864d91..a0c7ae80 100644 --- a/src/Cluster/Distributor/HashRing.php +++ b/src/Cluster/Distributor/HashRing.php @@ -161,7 +161,7 @@ class HashRing implements DistributorInterface, HashGeneratorInterface $replicas = (int) round($weightRatio * $totalNodes * $replicas); for ($i = 0; $i < $replicas; ++$i) { - $key = crc32("$nodeHash:$i"); + $key = $this->hash("$nodeHash:$i"); $ring[$key] = $nodeObject; } } From 2b8af1eef260c250449951e101b34326a60e9c7c Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Sun, 23 Aug 2020 18:38:07 +0200 Subject: [PATCH 8/9] Update CHANGELOG. --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64425506..24a97d7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ v1.1.4 (2020-xx-xx) will return an iterator that will run for just one loop returning a new client instance using the underlying single-node connection (ISSUE #552, PR #556). +- __FIX__: `Predis\Cluster\Distributor\HashRingaddNodeToRing()` was calculating + the hash required for distribution by using `crc32()` directly instead of the + method `Predis\Cluster\Hash\HashGeneratorInterface::hash()` implemented by the + class itself. This bug fix does not have any impact on existing clusters that + use client-side sharding based on this distributor simply because it does not + take any external hash generators so distribution is not going to be affected. + v1.1.3 (2020-08-18) ================================================================================ From 17f0c08cb6cb47015b127e862404869da050e4e2 Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Mon, 24 Aug 2020 11:45:20 +0200 Subject: [PATCH 9/9] [tests] Fix expected response for COMMAND INFO (Redis >= 6.0). Starting with Redis 6.0 and the introduction of Access Control Lists, COMMAND INFO returns an additional array for each specified command in the request with a list of the ACL categories associated to a command. --- tests/Predis/Command/ServerCommandTest.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/Predis/Command/ServerCommandTest.php b/tests/Predis/Command/ServerCommandTest.php index a4aa4080..c89a8283 100644 --- a/tests/Predis/Command/ServerCommandTest.php +++ b/tests/Predis/Command/ServerCommandTest.php @@ -102,13 +102,24 @@ class ServerCommandTest extends PredisCommandTestCase { $redis = $this->getClient(); + $expected = array(array('get', 2, array('readonly', 'fast'), 1, 1, 1)); + + // NOTE: starting with Redis 6.0 and the introduction of Access Control + // Lists, COMMAND INFO returns an additional array for each specified + // command in yhe request with a list of the ACL categories associated + // to a command. We simply append this additional array in the expected + // response if the test suite is executed against Redis >= 6.0. + if ($this->isRedisServerVersion('>=', '6.0')) { + $expected[0][] = array('@read', '@string', '@fast'); + } + + $this->assertCount(1, $response = $redis->command('INFO', 'GET')); + // NOTE: we use assertEquals instead of assertSame because Redis returns // flags as +STATUS responses, represented by Predis with instances of // Predis\Response\Status instead of plain strings. This class responds // to __toString() so the string conversion is implicit, but assertSame // checks for strict equality while assertEquals is loose. - $expected = array(array('get', 2, array('readonly', 'fast'), 1, 1, 1)); - $this->assertCount(1, $response = $redis->command('INFO', 'GET')); $this->assertEquals($expected, $response); }