Skip to content

Commit

Permalink
Fix bug where we need to array_values data_order so when we json conv…
Browse files Browse the repository at this point in the history
…ert, we don't end up with a hash instead of an array because of a missing array element.
  • Loading branch information
mark-unwin committed Jan 29, 2018
1 parent a406d12 commit 61a8f5a
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions code_igniter/application/helpers/output_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ function output()
}
} else {

unset($CI->response->meta->data_order);
$CI->response->meta->data_order = array();

if (!empty($CI->response->data)) {
$CI->response->meta->data_order = array();
foreach ($CI->response->data[0]->attributes as $key => $value) {
$CI->response->meta->data_order[] = $key;
}
Expand Down Expand Up @@ -130,6 +132,7 @@ function output()
}

$CI->response->meta->data_order = array_unique($CI->response->meta->data_order);
$CI->response->meta->data_order = array_values($CI->response->meta->data_order);
}


Expand Down Expand Up @@ -254,7 +257,7 @@ function output_csv()
$table = 'system';
}

#$CI->response->meta->data_order = array_values($CI->response->meta->data_order);
$CI->response->meta->data_order = array_values($CI->response->meta->data_order);
$csv_header = $CI->response->meta->data_order;
if ($CI->response->meta->collection != 'credentials' and
$CI->response->meta->collection != 'discoveries' and
Expand Down Expand Up @@ -326,18 +329,6 @@ function output_json()
$filename = 'openaudit';
}

if (($CI->response->meta->collection == 'queries' and $CI->response->meta->action == 'execute') or
($CI->response->meta->collection == 'devices' and $CI->response->meta->sub_resource == 'group') or
($CI->response->meta->collection == 'summaries' and $CI->response->meta->action == 'execute')) {
if (!empty($CI->response->data)) {
unset ($CI->response->meta->data_order);
$CI->response->meta->data_order = array();
foreach ($CI->response->data[0]->attributes as $key => $value) {
$CI->response->meta->data_order[] = $key;
}
}
}

header('Content-Type: application/json');
if ((string) $CI->config->item('download_reports') === 'download') {
header('Content-Disposition: attachment;filename="'.$filename.'.json"');
Expand Down

0 comments on commit 61a8f5a

Please sign in to comment.