Skip to content
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

[5.4] Fix PhpRedis’ ZADD #17832

Merged
merged 3 commits into from
Feb 9, 2017
Merged
Changes from 2 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
15 changes: 7 additions & 8 deletions src/Illuminate/Redis/Connections/PhpRedisConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,18 @@ 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 = [];

foreach ($membersAndScoresDictionary as $score => $member) {
$arguments[] = $score;
$arguments[] = $member;
if (count($dictionary) === 1) {
$dictionary = call_user_func_array('array_merge', call_user_func_array('array_map',
[null, array_values($dictionary[0]), array_keys($dictionary[0])]
));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯wathanized 💥

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I have no idea what is happening there. lol

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to use a simpler approach that is easier to read on first glance?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, a simple for loop and a temporary variable. I'll push another commit in a few.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: 5de9a67

}

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

/**
Expand Down