Skip to content

Commit

Permalink
[create_timepoint] Fix type errors in timepoint creation (aces#9361)
Browse files Browse the repository at this point in the history
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.

Fixes aces#9357
  • Loading branch information
driusan authored and ZhichGaming committed Nov 25, 2024
1 parent 950aeaf commit 046268f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions modules/create_timepoint/php/timepoint.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}

Expand Down Expand Up @@ -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);
Expand All @@ -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(
Expand Down

0 comments on commit 046268f

Please sign in to comment.