Compare commits

...

2 Commits

Author SHA1 Message Date
Sergey Sannikov 675951360f Fix RESP3 double parsing returning positive INF for -inf (#1716)
parseDouble() returned positive INF for the RESP3 payload ',-inf',
inverting the sign. The value is reachable with protocol=3, for
example ZSCORE on a member whose score is -inf.

The existing infinity test asserted only is_infinite(), which cannot
detect the sign inversion, so it now checks exact values.

NaN payloads keep their current behavior; that is addressed
separately.
2026-08-27 16:46:39 +03:00
Till Krüss 0795d69d9e bump dev version 2026-08-14 16:09:00 -07:00
5 changed files with 17 additions and 7 deletions
+6
View File
@@ -1,5 +1,11 @@
## Changelog
## Unlreleads
### Added
### Changed
### Fixed
- Fixed RESP3 double parsing returning positive `INF` for `-inf` payloads (#1716)
## v3.6.0 (2026-08-14)
### Added
- Added support for new TS commands + Indonesian language support integration test (#1695)
+1 -1
View File
@@ -1 +1 @@
3.6.0
3.6.1-dev
+1 -1
View File
@@ -56,7 +56,7 @@ use Traversable;
*/
class Client implements ClientInterface, IteratorAggregate
{
public const VERSION = '3.6.0';
public const VERSION = '3.6.1-dev';
/** @var OptionsInterface */
private $options;
@@ -63,10 +63,14 @@ class Resp3Strategy extends Resp2Strategy
*/
protected function parseDouble(string $string): float
{
if ($string === 'inf' || $string === '-inf') {
if ($string === 'inf') {
return INF;
}
if ($string === '-inf') {
return -INF;
}
return (float) $string;
}
@@ -60,11 +60,11 @@ class Resp3StrategyTest extends PredisTestCase
* @param string $data
* @return void
*/
public function testParseDataReturnsFloatInfinityOnInfinityOrNegativeInfinity(string $data): void
public function testParseDataReturnsFloatInfinityOnInfinityOrNegativeInfinity(string $data, float $expectedValue): void
{
$actualResponse = $this->strategy->parseData($data);
$this->assertInfinite($actualResponse);
$this->assertSame($expectedValue, $actualResponse);
}
/**
@@ -166,8 +166,8 @@ class Resp3StrategyTest extends PredisTestCase
public function infinityProvider(): array
{
return [
'positive infinity' => [",inf\r\n"],
'negative infinity' => [",-inf\r\n"],
'positive infinity' => [",inf\r\n", INF],
'negative infinity' => [",-inf\r\n", -INF],
];
}