Compare commits

..

15 Commits

Author SHA1 Message Date
Till Krüss b240daa106 tag v1.1.7 2021-04-04 12:34:46 -07:00
Till Krüss 8fee6ce8c3 Fix PHP 5.3 test and PHP 8 test runs
For some reason Xdebug causes a seg fault under PHP 8 on Travis CI.
2021-04-04 12:33:59 -07:00
Till Krüss 35dd44b222 Merge pull request #686 from remicollet/issue-redis62
fix test expectation for redis 6.2
2021-04-04 10:36:02 -07:00
Till Krüss 545177f09f Merge pull request #685 from BrianMwit/patch-1
Fix misleading argument name in SentinelReplication
2021-04-04 10:34:53 -07:00
Remi Collet 2f9337cb9b fix test expectation for redis 6.2 2021-03-18 11:08:37 +01:00
Pitchaya Boonsarngsuk 437d80a7a3 Fix misleading argument name in SentinelReplication
$this->retryWait is in milliseconds. It's setter misleadingly document it as seconds.
Fixing by renaming the argument variable name without altering the functionality.
2021-03-17 03:41:03 +00:00
Till Krüss 3a14a39d92 Merge pull request #678 from nicolas-grekas/ret-type
Add some return types
2021-02-09 10:09:19 -08:00
Till Krüss 5c9457cc2e Merge pull request #673 from roborourke/apply-patches-on-update
Apply patches on initial install/update
2021-02-09 09:44:11 -08:00
Nicolas Grekas c551fc21f9 Add some return types 2021-02-04 12:06:26 +01:00
Robert O'Rourke 0d84606723 Switch to old array style syntax to support PHP 5.3 2020-11-30 11:07:54 +00:00
Robert O'Rourke c021e380d6 Apply patches on initial install/update
The patches to get PHPUnit working are causing problems for other projects that use both `cweagans/composer-patch-installers` and `predis/predis` along with PHPUnit.

This change moves the patch application to a simple PHP script run on the `post-update-cmd` composer event and removes the dependency on the patch installers package.
2020-11-27 17:24:00 +00:00
Daniele Alessandri 5f4b87080f Tweak tests. 2020-09-20 17:16:49 +02:00
Daniele Alessandri 5ae4ac6b49 Clear pending responses in reader buffer on disconnect.
When using the phpiredis-based connection backends, failed pipelines led
to spurious responses returned after reconnecting to Redis because the
underlying reader was not properly reset by discarding buffered replies
after disconnecting.

Fixes a couple of issues reported in #363.
2020-09-20 16:58:18 +02:00
Daniele Alessandri 521ac8f0eb Fix PhpiredisSocketConnection for PHP 8.
Removed is_resource() check as socket_create() now returns an object.
2020-09-20 15:27:35 +02:00
Daniele Alessandri fbbef2a0a2 Back to development. 2020-09-11 21:20:11 +02:00
19 changed files with 114 additions and 42 deletions
+3 -1
View File
@@ -9,6 +9,7 @@ branches:
before_install:
- docker run -d --rm -p 127.0.0.1:6379:6379 redis:3
before_script:
- phpenv config-rm xdebug.ini
- composer self-update
- composer install --no-interaction --prefer-source --dev
script:
@@ -30,6 +31,7 @@ matrix:
- php: 7.2
- php: 7.3
- php: 7.4
- php: nightly # PHP 8.0.0-dev
- php: 8.0
- php: nightly
allow_failures:
- php: nightly
+11
View File
@@ -1,3 +1,14 @@
v1.1.7 (2021-04-04)
================================================================================
- __FIX__: with the phpiredis-based connection backends, failed pipelines led to
spurious responses returned after reconnecting to Redis because the underlying
reader was not properly reset by discarding buffered replies after disconnecting
(ISSUE #363).
- __FIX__: removed `cweagans/composer-patches` dev dependency and apply patches
using `post-update-cmd` script.
v1.1.6 (2020-09-11)
================================================================================
+1 -1
View File
@@ -1 +1 @@
1.1.6
1.1.7
+4 -14
View File
@@ -31,8 +31,7 @@
"php": ">=5.3.9"
},
"require-dev": {
"phpunit/phpunit": "~4.8",
"cweagans/composer-patches": "^1.6"
"phpunit/phpunit": "~4.8"
},
"suggest": {
"ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol",
@@ -43,16 +42,7 @@
"Predis\\": "src/"
}
},
"extra": {
"composer-exit-on-patch-failure": true,
"patches": {
"phpunit/phpunit-mock-objects": {
"Fix PHP 7 and 8 compatibility": "./tests/phpunit_mock_objects.patch"
},
"phpunit/phpunit": {
"Fix PHP 7 compatibility": "./tests/phpunit_php7.patch",
"Fix PHP 8 compatibility": "./tests/phpunit_php8.patch"
}
}
}
"scripts": {
"post-update-cmd": "@php -f tests/apply-patches.php"
}
}
+1 -1
View File
@@ -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.6"
version = "1.1.7"
stability = "stable"
channel = "pear.nrk.io"
-4
View File
@@ -36,10 +36,6 @@
</whitelist>
</filter>
<logging>
<log type="coverage-text" target="php://stdout" />
</logging>
<php>
<!-- Redis -->
<const name="REDIS_SERVER_VERSION" value="3.2" />
+2 -2
View File
@@ -40,7 +40,7 @@ use Predis\Transaction\MultiExec as MultiExecTransaction;
*/
class Client implements ClientInterface, \IteratorAggregate
{
const VERSION = '1.1.6';
const VERSION = '1.1.7';
protected $connection;
protected $options;
@@ -527,7 +527,7 @@ class Client implements ClientInterface, \IteratorAggregate
}
/**
* {@inheritdoc}
* @return \Traversable<string, static>
*/
public function getIterator()
{
+2 -2
View File
@@ -71,7 +71,7 @@ class ProcessorChain implements \ArrayAccess, ProcessorInterface
/**
* Returns an iterator over the list of command processor in the chain.
*
* @return \ArrayIterator
* @return \Traversable<int, ProcessorInterface>
*/
public function getIterator()
{
@@ -89,7 +89,7 @@ class ProcessorChain implements \ArrayAccess, ProcessorInterface
}
/**
* {@inheritdoc}
* @return bool
*/
public function offsetExists($index)
{
+2 -2
View File
@@ -176,7 +176,7 @@ class PredisCluster implements ClusterInterface, \IteratorAggregate, \Countable
}
/**
* {@inheritdoc}
* @return int
*/
public function count()
{
@@ -184,7 +184,7 @@ class PredisCluster implements ClusterInterface, \IteratorAggregate, \Countable
}
/**
* {@inheritdoc}
* @return \Traversable<string|int, NodeConnectionInterface>
*/
public function getIterator()
{
+2 -2
View File
@@ -600,7 +600,7 @@ class RedisCluster implements ClusterInterface, \IteratorAggregate, \Countable
}
/**
* {@inheritdoc}
* @return int
*/
public function count()
{
@@ -608,7 +608,7 @@ class RedisCluster implements ClusterInterface, \IteratorAggregate, \Countable
}
/**
* {@inheritdoc}
* @return \Traversable<int, NodeConnectionInterface>
*/
public function getIterator()
{
@@ -146,14 +146,14 @@ class SentinelReplication implements ReplicationInterface
}
/**
* Sets the time to wait (in seconds) before fetching a new configuration
* Sets the time to wait (in milliseconds) before fetching a new configuration
* from one of the sentinels.
*
* @param float $seconds Time to wait before the next attempt.
* @param float $milliseconds Time to wait before the next attempt.
*/
public function setRetryWait($seconds)
public function setRetryWait($milliseconds)
{
$this->retryWait = (float) $seconds;
$this->retryWait = (float) $milliseconds;
}
/**
+5 -5
View File
@@ -66,9 +66,9 @@ class PhpiredisSocketConnection extends AbstractConnection
*/
public function __destruct()
{
phpiredis_reader_destroy($this->reader);
parent::__destruct();
phpiredis_reader_destroy($this->reader);
}
/**
@@ -227,9 +227,7 @@ class PhpiredisSocketConnection extends AbstractConnection
$protocol = SOL_TCP;
}
$socket = @socket_create($domain, SOCK_STREAM, $protocol);
if (!is_resource($socket)) {
if (false === $socket = @socket_create($domain, SOCK_STREAM, $protocol)) {
$this->emitSocketError();
}
@@ -344,7 +342,9 @@ class PhpiredisSocketConnection extends AbstractConnection
public function disconnect()
{
if ($this->isConnected()) {
phpiredis_reader_reset($this->reader);
socket_close($this->getResource());
parent::disconnect();
}
}
+12 -2
View File
@@ -67,9 +67,19 @@ class PhpiredisStreamConnection extends StreamConnection
*/
public function __destruct()
{
phpiredis_reader_destroy($this->reader);
parent::__destruct();
phpiredis_reader_destroy($this->reader);
}
/**
* {@inheritdoc}
*/
public function disconnect()
{
phpiredis_reader_reset($this->reader);
parent::disconnect();
}
/**
@@ -83,7 +83,7 @@ class ConnectionSelectTest extends PredisCommandTestCase
/**
* @group connected
* @expectedException \Predis\Response\ServerException
* @expectedExceptionMessage ERR invalid DB index
* @expectedExceptionMessageRegExp /ERR (invalid DB index|value is not)/
*/
public function testThrowsExceptionOnUnexpectedDatabaseName()
{
+1 -1
View File
@@ -82,7 +82,7 @@ class KeyMoveTest extends PredisCommandTestCase
/**
* @group connected
* @expectedException \Predis\Response\ServerException
* @expectedExceptionMessage ERR index out of range
* @expectedExceptionMessageRegEx /ERR.*out of range/
*/
public function testThrowsExceptionOnInvalidDatabases()
{
@@ -66,6 +66,10 @@ class ReplicationOptionTest extends PredisTestCase
*/
public function testDoesNotAcceptValuesThatCanBeInterpretedAsBooleanFalse($value)
{
if (version_compare(PHP_VERSION, '5.4', '<')) {
$this->markTestSkipped('Skip test, because.');
}
$option = new ReplicationOption();
$options = $this->getMock('Predis\Configuration\OptionsInterface');
@@ -76,6 +76,28 @@ class PhpiredisSocketConnectionTest extends PredisConnectionTestCase
// ---- INTEGRATION TESTS --------------------------------------------- //
// ******************************************************************** //
/**
* @group connected
*/
public function testClearsPendingResponsesInReaderBufferOnDisconnect()
{
$profile = $this->getCurrentProfile();
$connection = $this->createConnection();
$cmdECHOBefore = $profile->createCommand('echo', array('BEFORE DISCONNECT'));
$cmdECHOAfter = $profile->createCommand('echo', array('AFTER DISCONNECT'));
$connection->writeRequest($cmdECHOBefore);
$connection->writeRequest($cmdECHOBefore);
$connection->writeRequest($cmdECHOBefore);
$connection->readResponse($cmdECHOBefore);
$connection->disconnect();
$response = $connection->executeCommand($cmdECHOAfter);
$this->assertSame('AFTER DISCONNECT', $response);
}
/**
* @group connected
* @expectedException \Predis\Connection\ConnectionException
@@ -76,6 +76,28 @@ class PhpiredisStreamConnectionTest extends PredisConnectionTestCase
// ---- INTEGRATION TESTS --------------------------------------------- //
// ******************************************************************** //
/**
* @group connected
*/
public function testClearsPendingResponsesInReaderBufferOnDisconnect()
{
$profile = $this->getCurrentProfile();
$connection = $this->createConnection();
$cmdECHOBefore = $profile->createCommand('echo', array('BEFORE DISCONNECT'));
$cmdECHOAfter = $profile->createCommand('echo', array('AFTER DISCONNECT'));
$connection->writeRequest($cmdECHOBefore);
$connection->writeRequest($cmdECHOBefore);
$connection->writeRequest($cmdECHOBefore);
$connection->readResponse($cmdECHOBefore);
$connection->disconnect();
$response = $connection->executeCommand($cmdECHOAfter);
$this->assertSame('AFTER DISCONNECT', $response);
}
/**
* @group connected
* @group slow
+15
View File
@@ -0,0 +1,15 @@
<?php
/**
* Apply patches to support newer PHP versions.
*/
$patches = array(
'phpunit_mock_objects.patch' => 'phpunit/phpunit-mock-objects',
'phpunit_php7.patch' => 'phpunit/phpunit',
'phpunit_php8.patch' => 'phpunit/phpunit',
);
foreach ($patches as $patch => $package) {
chdir(__DIR__.'/../vendor/'.$package);
passthru(sprintf('patch -p1 -f < ../../../tests/%s', $patch));
}