Skip to content

Commit

Permalink
send fields as a string
Browse files Browse the repository at this point in the history
  • Loading branch information
70ray committed Dec 13, 2024
1 parent cbee2a3 commit 32a4aa3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions SETUP/tests/unittests/ApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ public function test_get_page_data(): void
public function test_get_round_type_none(): void
{
$project = $this->_create_project();
$result = $this->get_project_data($project->projectid, ["field" => "round_type"]);
$this->assertEquals(["round_type" => "none"], $result);
$result = $this->get_project_data($project->projectid, ["field" => "title,round_type"]);
$this->assertEquals(["title" => "War and Peace", "round_type" => "none"], $result);
}

public function test_get_round_type_proofreading(): void
Expand Down
5 changes: 3 additions & 2 deletions api/v1_projects.inc
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ include_once("api_common.inc");
*/
function get_return_fields(?array $query_params, ?Project $project)
{
$return_fields = array_get_as_array($query_params, "field", null);
if (is_null($return_fields)) {
$field = $query_params["field"] ?? null;
if (is_null($field)) {
return null;
}
$return_fields = explode(",", $field);
$valid_render_fields = array_keys(get_project_fields_with_attr(null, $project));
$invalid_fields = array_diff($return_fields, $valid_render_fields);
if (!empty($invalid_fields)) {
Expand Down

0 comments on commit 32a4aa3

Please sign in to comment.