Browse files

Fix: arguments of dimension higher than 2 cause notice level error in…

… command logging.
  • Loading branch information...
1 parent 57f7fd1 commit 66aaa82d7939a18ff9a72b64ab0ffb4308a9f12e Mo Di committed Aug 13, 2012
Showing with 25 additions and 1 deletion.
  1. +25 −1 Client/Phpredis/Client.php
View
26 Client/Phpredis/Client.php
@@ -103,6 +103,30 @@ public function __call($name, array $arguments)
*/
private function getCommandString($command, array $arguments)
{
- return trim(strtoupper($command) . ' ' . implode(' ', (array) array_pop($arguments)));
+ $list = array();
+ $this->flatten($arguments, $list);
+
+ return trim(strtoupper($command) . ' ' . implode(' ', $list));
+ }
+
+ /**
+ * Flatten arguments to single dimension array
+ *
+ * @param array $arguments An array of command arguments
+ * @param array $list Holder of results
+ */
+ private function flatten($arguments, array &$list)
+ {
+ foreach ($arguments as $key => $item) {
+ if (!is_numeric($key)) {
+ $list[] = $key;
+ }
+
+ if (is_scalar($item)) {
+ $list[] = strval($item);
+ } else {
+ $this->flatten($item, $list);
+ }
+ }
}
}

0 comments on commit 66aaa82

Please sign in to comment.