浏览代码

Make the reply parser for INFO < 2.4 somewhat backwards compatible when used against Redis >= 2.4.

Daniele Alessandri 14 年之前
父节点
当前提交
58eb4e2477
共有 1 个文件被更改,包括 5 次插入2 次删除
  1. 5 2
      lib/Predis/Commands/Info.php

+ 5 - 2
lib/Predis/Commands/Info.php

@@ -9,7 +9,10 @@ class Info extends Command {
         $info      = array();
         $info      = array();
         $infoLines = explode("\r\n", $data, -1);
         $infoLines = explode("\r\n", $data, -1);
         foreach ($infoLines as $row) {
         foreach ($infoLines as $row) {
-            list($k, $v) = explode(':', $row);
+            @list($k, $v) = explode(':', $row);
+            if ($row === '' || !isset($v)) {
+                continue;
+            }
             if (!preg_match('/^db\d+$/', $k)) {
             if (!preg_match('/^db\d+$/', $k)) {
                 if ($k === 'allocation_stats') {
                 if ($k === 'allocation_stats') {
                     $info[$k] = $this->parseAllocationStats($v);
                     $info[$k] = $this->parseAllocationStats($v);
@@ -31,7 +34,7 @@ class Info extends Command {
     protected function parseAllocationStats($str) {
     protected function parseAllocationStats($str) {
         $stats = array();
         $stats = array();
         foreach (explode(',', $str) as $kv) {
         foreach (explode(',', $str) as $kv) {
-            list($size, $objects, $extra) = explode('=', $kv);
+            @list($size, $objects, $extra) = explode('=', $kv);
             // hack to prevent incorrect values when parsing the >=256 key
             // hack to prevent incorrect values when parsing the >=256 key
             if (isset($extra)) {
             if (isset($extra)) {
                 $size = ">=$objects";
                 $size = ">=$objects";