From 32c1ab62545a5a2b90650c9ac31702258fa17c68 Mon Sep 17 00:00:00 2001 From: Dave MacFarlane Date: Wed, 25 Sep 2024 09:35:07 -0400 Subject: [PATCH 1/2] [create_timepoint] Fix type errors in timepoint creation LorisForm returns values as strings, but \ProjectID::singleton and \CenterID::singleton take integer values. This updates the singleton calls to cast as an int to fix the type errors on timepoint creation. --- modules/create_timepoint/php/timepoint.class.inc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/create_timepoint/php/timepoint.class.inc b/modules/create_timepoint/php/timepoint.class.inc index ea9b0c1e92d..950b83df411 100644 --- a/modules/create_timepoint/php/timepoint.class.inc +++ b/modules/create_timepoint/php/timepoint.class.inc @@ -151,7 +151,7 @@ class Timepoint extends \NDB_Page implements ETagCalculator if ($num_sites == 1) { $site = \Site::singleton($user_list_of_sites[0]); } else if ($num_sites > 1) { - $site = \Site::singleton(\CenterID::singleton(($values['psc']))); + $site = \Site::singleton(\CenterID::singleton((intval($values['psc'])))); } // Project @@ -161,7 +161,7 @@ class Timepoint extends \NDB_Page implements ETagCalculator // if there is only one project, autoselect first project from array of 1 $project = \Project::getProjectFromID(array_pop($user_list_of_projects)); } else if (count($user_list_of_projects) > 1) { - $project_id = \ProjectID::singleton($values['project']); + $project_id = \ProjectID::singleton(intval($values['project'])); $project = \Project::getProjectFromID($project_id); } @@ -234,7 +234,9 @@ class Timepoint extends \NDB_Page implements ETagCalculator null : $values['psc']; // validate site entered - $site = !empty($values['psc']) ? \CenterID::singleton($values['psc']) : null; + $site = !empty($values['psc']) + ? \CenterID::singleton(intval($values['psc'])) + : null; $user_list_of_sites = $user->getCenterIDs(); $num_sites = count($user_list_of_sites); @@ -261,7 +263,7 @@ class Timepoint extends \NDB_Page implements ETagCalculator $candid = $values['candID']; $cohortID = intval($values['cohort']); - $projectID = \ProjectID::singleton($values['project']); + $projectID = \ProjectID::singleton(intval($values['project'])); //Visit - Get all visits to map ID back to label for session table $visits = \Utility::getVisitsForProjectCohort( From 6c96b8e93101bccb4c8c1e2a95ef37d9844a14b1 Mon Sep 17 00:00:00 2001 From: Dave MacFarlane Date: Wed, 25 Sep 2024 10:37:33 -0400 Subject: [PATCH 2/2] Indent terniary operator --- modules/create_timepoint/php/timepoint.class.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/create_timepoint/php/timepoint.class.inc b/modules/create_timepoint/php/timepoint.class.inc index 950b83df411..878a3a6ba4f 100644 --- a/modules/create_timepoint/php/timepoint.class.inc +++ b/modules/create_timepoint/php/timepoint.class.inc @@ -235,8 +235,8 @@ class Timepoint extends \NDB_Page implements ETagCalculator // validate site entered $site = !empty($values['psc']) - ? \CenterID::singleton(intval($values['psc'])) - : null; + ? \CenterID::singleton(intval($values['psc'])) + : null; $user_list_of_sites = $user->getCenterIDs(); $num_sites = count($user_list_of_sites);