diff --git a/SETUP/tests/unittests/ApiTest.php b/SETUP/tests/unittests/ApiTest.php index c81f7fb8f..5d8d0cedf 100644 --- a/SETUP/tests/unittests/ApiTest.php +++ b/SETUP/tests/unittests/ApiTest.php @@ -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 diff --git a/api/v1_projects.inc b/api/v1_projects.inc index 3271a44a2..030cce4d8 100644 --- a/api/v1_projects.inc +++ b/api/v1_projects.inc @@ -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)) {