-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Core] PSCID uniqueness #8411
[Core] PSCID uniqueness #8411
Conversation
finishing tests
@@ -241,7 +241,7 @@ class Candidates extends Endpoint implements \LORIS\Middleware\ETagCalculator | |||
$pscid, | |||
$project->getId() | |||
); | |||
} catch (\LorisException | \InvalidArgumentException $e) { | |||
} catch (\Exception | \LorisException | \InvalidArgumentException $e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When is a \LorisException
or an \InvalidArgumentException
not an \Exception
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When PSCID is not provided and generation is user
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean that by adding \Exception I should remove the other two because they are subclasses?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was my question, yes.
@kongtiaowang would you know why this is failing? I'am not changing the file that triggers the error. |
It looks like it's the test that you're adding in the PR that's failing?
|
My bad, I was looking a the warning. Thanks, I'll look into it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API docs says PSCID uniqueness throws 409 but i believe this throws 400. can we resolve this either in the docs or in the endpoint?
otherwise, the code does work to not let candidate creation happen if PSCID already exists
curl -H "Authorization: Bearer $token" https://copn-stg.loris.ca/api/v0.0.3/candidates -d '{"Candidate":{"PSCID":"MNI0054","Project":"COPN","Site":"Montreal Neurological Institute","DoB":"1998-01","Sex":"Female"}}'
{"error":"PSCID must be unique"}
@xlecours i can review/test once testing is fixed/passes |
Looks like it's just PHPCS:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicate PSCID is not created but no error is thrown
lorisadmin@copn-dev:/var/www/loris/project$ curl -H "Authorizatio/api/v0.0.3/candidates -d '{"Candidate":{"PSCID":"MNI0054","Project":"COPN","Site":"Montreal Neurological Institute","DoB":"1998-01-01","Sex":"Female"}}'
{"CandID":"148989","Project":"COPN","PSCID":"MNI0054","Site":"Montreal Neurological Institute","EDC":null,"DoB":"1998-01-01","Sex":"Female"}
lorisadmin@copn-dev:/var/www/loris/project$ curl -H "Authorization: Bearer $/api/v0.0.3/candidates -d '{"Candidate":{"PSCID":"MNI0054","Project":"COPN","Site":"Montreal Neurological Institute","DoB":"1998-01-01","Sex":"Female"}}'
@zaliqarosli Can you try with |
@xlecours 500 error, Conflict Exception class not found ..
this might be specific to my set up. i'll look into it, but anything obvious sticking out to you? |
Have you run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested again and it works great 💪
Brief summary of changes
Add PSCID uniqueness check to Candidate::createNew.
To test:
user
in yoru config file.PSCID must be unique