-
Notifications
You must be signed in to change notification settings - Fork 529
Closed
Description
When using the feed API to export a CSV file (.../feed/data.json?id=...&csv=1), the downloaded CSV file contains null for values that should be 0.
The bug seems to be in Modules/feed/engine/shared_helper.php in the functions csv_write and csv_write_multi:
public function csv_write($time,$value) {
$time = $this->format_time($time);
if ($value!=null) {
$value = number_format($value,$this->csv_dp,$this->csv_dp_separator,'');
} else {
$value = 'null';
}
fwrite($this->export_fh,$time.$this->csv_field_separator.$value."\n");
}
public function csv_write_multi($values) {
// $values[0] = $this->format_time($values[0]);
for ($z=1; $z<count($values); $z++) {
if ($values[$z]==null) {
$values[$z] = 'null';
} else {
$values[$z] = number_format($values[$z],$this->csv_dp,$this->csv_dp_separator,'');
}
}
fwrite($this->export_fh,implode($this->csv_field_separator,$values)."\n");
}
The lines if ($value!=null) { and if ($values[$z]==null) { should use the PHP identity operator === rather than equality == to distinguish between null values and zero values.
Metadata
Metadata
Assignees
Labels
No labels