Skip to content

Commit

Permalink
[API] fix POST to candidates type error (aces#6877)
Browse files Browse the repository at this point in the history
Fix for error:

```
PHP Fatal error: Uncaught TypeError: Argument 4 passed to Candidate::createNew() must be an instance of LORIS\\StudyEntities\\Candidate\\Sex, string given, called in /var/www/loris/modules/api/php/endpoints/candidates.class.inc on line 213
```

while POSTing to API to create a candidate.
  • Loading branch information
ridz1208 authored and AlexandraLivadas committed Jun 29, 2021
1 parent b4c70ab commit 3d4bc5c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion modules/api/php/endpoints/candidates.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
namespace LORIS\api\Endpoints;

use LORIS\StudyEntities\Candidate\Sex;
use \Psr\Http\Message\ServerRequestInterface;
use \Psr\Http\Message\ResponseInterface;
use \LORIS\api\Endpoint;
Expand Down Expand Up @@ -203,12 +204,14 @@ class Candidates extends Endpoint implements \LORIS\Middleware\ETagCalculator

$pscid = $data['Candidate']['PSCID'] ?? null;

$sex = new Sex($data['Candidate']['Sex']);

try {
$candid = \Candidate::createNew(
$centerid,
$data['Candidate']['DoB'],
$data['Candidate']['EDC'],
$data['Candidate']['Sex'],
$sex,
$pscid,
$project->getId()
);
Expand Down

0 comments on commit 3d4bc5c

Please sign in to comment.