Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/supremm_module_warnings' into su…
Browse files Browse the repository at this point in the history
…pport_jobarrays
  • Loading branch information
jpwhite4 committed May 22, 2023
2 parents f2f6ac7 + b209be4 commit a60611e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
14 changes: 13 additions & 1 deletion classes/DataWarehouse/Access/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ public function __construct($request) {

protected function checkDateParameters()
{
if (!isset($this->request['start_date'])) {
throw new \DataWarehouse\Query\Exceptions\BadRequestException(
'missing required start_date parameter'
);
}

$start_date_parsed = date_parse_from_format(
'Y-m-d',
$this->request['start_date']
Expand All @@ -56,6 +62,12 @@ protected function checkDateParameters()
);
}

if (!isset($this->request['end_date'])) {
throw new \DataWarehouse\Query\Exceptions\BadRequestException(
'missing required end_date parameter'
);
}

$end_date_parsed = date_parse_from_format('Y-m-d', $this->request['end_date']);

if ($end_date_parsed['error_count'] !== 0) {
Expand Down Expand Up @@ -178,7 +190,7 @@ protected function getFontSize()
return
isset($this->request['font_size']) && $this->request['font_size'] != ''
? $this->request['font_size']
: 'default';
: '3';
}

protected function getTitle()
Expand Down
5 changes: 5 additions & 0 deletions classes/DataWarehouse/Access/MetricExplorer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use DataWarehouse\Query\Exceptions\AccessDeniedException;
use DataWarehouse\Query\Exceptions\MissingFilterListTableException;
use DataWarehouse\Query\Exceptions\UnknownGroupByException;
use DataWarehouse\Query\Exceptions\BadRequestException;
use FilterListHelper;
use XDUser;

Expand Down Expand Up @@ -411,6 +412,10 @@ private function getDataSeries()

$jret = json_decode($ret);

if (!is_array($jret)) {
throw new BadRequestException('Invalid data_series specified');
}

foreach ($jret as &$y) {

// Set values of new attribs for backward compatibility.
Expand Down
2 changes: 1 addition & 1 deletion classes/Rest/Controllers/WarehouseControllerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ public function updateHistory(Request $request, Application $app, $id)
array(
'success' => true,
'action' => $action,
'total' => count($history),
'total' => count($result),
'results' => $result
),
200
Expand Down
10 changes: 9 additions & 1 deletion tests/integration/lib/Controllers/UsageExplorerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,18 @@ public function corruptDataProvider()
"controller_module"=> "user_interface"
);

$view['start_date'] = null;
$tests[] = array($view, 'missing required start_date parameter');

$view['start_date'] = '2017-05-01';
$view['end_date'] = null;
$tests[] = array($view, 'missing required end_date parameter');

$view['end_date'] = 'Yesterday';
$tests[] = array($view, 'end_date param is not in the correct format of Y-m-d.');

$view['start_date'] = null;
$view['start_date'] = 'Tomorrow';
$view['end_date'] = '2017-05-01';
$tests[] = array($view, 'start_date param is not in the correct format of Y-m-d.');

$view['group_by'] = "elephants";
Expand Down

0 comments on commit a60611e

Please sign in to comment.