Fix support options array in ZINTERSTORE and ZUNIONSTORE (#1018)

* support old options array

* fix zinterstore as well

* single override
This commit is contained in:
Till Krüss
2023-01-17 12:50:15 -08:00
committed by GitHub
parent 2bfc8a9316
commit 836ab07d40
3 changed files with 23 additions and 2 deletions
+7
View File
@@ -50,6 +50,13 @@ class ZUNIONSTORE extends RedisCommand
*/
public function setArguments(array $arguments)
{
// support old `$options` array for backwards compatibility
if (! isset($arguments[3]) && (isset($arguments[2]['weights']) || isset($arguments[2]['aggregate']))) {
$options = array_pop($arguments);
array_push($arguments, $options['weights'] ?? []);
array_push($arguments, $options['aggregate'] ?? 'sum');
}
$this->setAggregate($arguments);
$arguments = $this->getArguments();
@@ -153,7 +153,14 @@ class ZINTERSTORE_Test extends PredisCommandTestCase
'with all arguments' => [
['destination', ['key1', 'key2'], [1, 2], 'min'],
['destination', 2, 'key1', 'key2', 'WEIGHTS', 1, 2, 'AGGREGATE', 'MIN'],
]
],
'with options array' => [
['destination', ['key1', 'key2'], [
'weights' => [1, 2],
'aggregate' => 'min',
]],
['destination', 2, 'key1', 'key2', 'WEIGHTS', 1, 2, 'AGGREGATE', 'MIN'],
],
];
}
@@ -153,7 +153,14 @@ class ZUNIONSTORE_Test extends PredisCommandTestCase
'with all arguments' => [
['destination', ['key1', 'key2'], [1, 2], 'min'],
['destination', 2, 'key1', 'key2', 'WEIGHTS', 1, 2, 'AGGREGATE', 'MIN'],
]
],
'with options array' => [
['destination', ['key1', 'key2'], [
'weights' => [1, 2],
'aggregate' => 'min',
]],
['destination', 2, 'key1', 'key2', 'WEIGHTS', 1, 2, 'AGGREGATE', 'MIN'],
],
];
}