Skip to content

[5.4] Fix PhpRedis’ ZADD #17832

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 9, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/Illuminate/Redis/Connections/PhpRedisConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,23 @@ public function spop($key, $count = null)
* Add one or more members to a sorted set or update its score if it already exists.
*
* @param string $key
* @param array $membersAndScoresDictionary
* @param mixed $dictionary
* @return int
*/
public function zadd($key, array $membersAndScoresDictionary)
public function zadd($key, ...$dictionary)
{
$arguments = [];
if (count($dictionary) === 1) {
$_dictionary = [];

foreach ($membersAndScoresDictionary as $score => $member) {
$arguments[] = $score;
$arguments[] = $member;
foreach ($dictionary[0] as $member => $score) {
$_dictionary[] = $score;
$_dictionary[] = $member;
}

$dictionary = $_dictionary;
}

return $this->client->zadd($key, ...$arguments);
return $this->client->zadd($key, ...$dictionary);
}

/**
Expand Down