Use global dateFormatter to format time in ajax events response. Don't format Length as it loses precision. Let javascript side do it. Turn off error_reporting in the output as it breaks the json

pull/3494/head
Isaac Connor 2022-06-01 13:32:32 -04:00
parent 7c0dcfcefc
commit da0483f3e7
1 changed files with 5 additions and 4 deletions

View File

@ -1,4 +1,5 @@
<?php
error_reporting(0);
$message = '';
$data = array();
@ -140,11 +141,12 @@ function deleteRequest($eid) {
}
function queryRequest($filter, $search, $advsearch, $sort, $offset, $order, $limit) {
global $dateFormatter;
$data = array(
'total' => 0,
'totalNotFiltered' => 0,
'rows' => array(),
'updated' => preg_match('/%/', DATE_FMT_CONSOLE_LONG) ? strftime(DATE_FMT_CONSOLE_LONG) : date(DATE_FMT_CONSOLE_LONG)
'updated' => $dateFormatter->format(time())
);
$failed = !$filter->test_pre_sql_conditions();
@ -279,9 +281,8 @@ function queryRequest($filter, $search, $advsearch, $sort, $offset, $order, $lim
$row['Archived'] = $row['Archived'] ? translate('Yes') : translate('No');
$row['Emailed'] = $row['Emailed'] ? translate('Yes') : translate('No');
$row['Cause'] = validHtmlStr($row['Cause']);
$row['StartDateTime'] = strftime(STRF_FMT_DATETIME_SHORTER, strtotime($row['StartDateTime']));
$row['EndDateTime'] = $row['EndDateTime'] ? strftime(STRF_FMT_DATETIME_SHORTER, strtotime($row['EndDateTime'])) : null;
$row['Length'] = gmdate('H:i:s', $row['Length'] );
$row['StartDateTime'] = $dateFormatter->format(strtotime($row['StartDateTime']));
$row['EndDateTime'] = $row['EndDateTime'] ? $dateFormatter->format(strtotime($row['EndDateTime'])) : null;
$row['Storage'] = ( $row['StorageId'] and isset($StorageById[$row['StorageId']]) ) ? $StorageById[$row['StorageId']]->Name() : 'Default';
$row['Notes'] = nl2br(htmlspecialchars($row['Notes']));
$row['DiskSpace'] = human_filesize($event->DiskSpace());