mirror of
https://github.com/predis/predis.git
synced 2026-08-24 13:59:23 +00:00
fix #154
This commit is contained in:
@@ -34,27 +34,37 @@ class ServerInfo extends AbstractCommand
|
||||
$infoLines = preg_split('/\r?\n/', $data);
|
||||
|
||||
foreach ($infoLines as $row) {
|
||||
@list($k, $v) = explode(':', $row);
|
||||
|
||||
if ($row === '' || !isset($v)) {
|
||||
if (strpos($row, ':') === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!preg_match('/^db\d+$/', $k)) {
|
||||
if ($k === 'allocation_stats') {
|
||||
$info[$k] = $this->parseAllocationStats($v);
|
||||
continue;
|
||||
}
|
||||
|
||||
$info[$k] = $v;
|
||||
} else {
|
||||
$info[$k] = $this->parseDatabaseStats($v);
|
||||
}
|
||||
list($k, $v) = $this->parseRow($row);
|
||||
$info[$k] = $v;
|
||||
}
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses single row of the reply buffer and returns the key-value pair.
|
||||
*
|
||||
* @param string $row Single row of the reply buffer.
|
||||
* @return array
|
||||
*/
|
||||
public function parseRow($row)
|
||||
{
|
||||
list($k, $v) = explode(':', $row, 2);
|
||||
|
||||
if (!preg_match('/^db\d+$/', $k)) {
|
||||
if ($k === 'allocation_stats') {
|
||||
$v = $this->parseAllocationStats($v);
|
||||
}
|
||||
} else {
|
||||
$v = $this->parseDatabaseStats($v);
|
||||
}
|
||||
return [$k, $v];
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the reply buffer and extracts the statistics of each logical DB.
|
||||
*
|
||||
|
||||
@@ -41,18 +41,8 @@ class ServerInfoV26x extends ServerInfo
|
||||
continue;
|
||||
}
|
||||
|
||||
list($k, $v) = explode(':', $row);
|
||||
|
||||
if (!preg_match('/^db\d+$/', $k)) {
|
||||
if ($k === 'allocation_stats') {
|
||||
$current[$k] = $this->parseAllocationStats($v);
|
||||
continue;
|
||||
}
|
||||
|
||||
$current[$k] = $v;
|
||||
} else {
|
||||
$current[$k] = $this->parseDatabaseStats($v);
|
||||
}
|
||||
list($k, $v) = $this->parseRow($row);
|
||||
$current[$k] = $v;
|
||||
}
|
||||
|
||||
return $info;
|
||||
|
||||
Reference in New Issue
Block a user