Exception using getPoints on empty metric
andig opened this issue · comments
PHP Warning: Invalid argument supplied for foreach() in src/InfluxDB/ResultSet.php on line 68
Getting this warning when writing against Telegraf v1 listener
I think root cause is getSeries
which has meanwhile been modified:
public function getSeries()
{
$series = array_map(
function ($object) {
if (isset($object['error'])) {
throw new ClientException($object['error']);
}
return isset($object['series']) ? $object['series'] : [];
},
$this->parsedResults['results']
);
return array_shift($series);
}
array_shift($series);
on empty array will yield NULL
and hence yield the notice.
Seems this was changed in ba96a93. However, upgrading to 1.15, I'm getting:
In ResultSet.php line 107: Invalid statement index provided
I feel the reason is that in
influxdb-php/src/InfluxDB/ResultSet.php
Line 74 in 4a1efb4
getSeries()
is called without parameter which means default value of 0
.
In getSeries()
, in
influxdb-php/src/InfluxDB/ResultSet.php
Line 106 in 4a1efb4
0
series.
Is that the desired behaviour?