-
Notifications
You must be signed in to change notification settings - Fork 179
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
[Tools] Enable PHPCS for fix_timepoint_date_problems.php #6798
[Tools] Enable PHPCS for fix_timepoint_date_problems.php #6798
Conversation
949b7cc
to
e756f28
Compare
c7960b9
to
ac476f6
Compare
ac476f6
to
86453cf
Compare
86453cf
to
fefd9f0
Compare
fefd9f0
to
cba2763
Compare
Hi @laemtl! I was wondering if you could provide some information on how this could be tested? Thanks! |
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.
Hi @laemtl!
Here are some suggested improvements:
- Check that args are set
- When using
diagnose
, I am getting an error telling me it cannot diagnose a non-started timepoint even though the visits have been started.
$ php fix_timepoint_date_problems.php diagnose 676061
Candidate: 676061
Timepoint V1 ; SubProjectID: 2 ; Effective DOB: 1980-02-02 ; (SessionID): 2145
Error: failed to get the list of needed instruments for candidate (676061), timepoint (2145):
Error: Cannot diagnose the non-started timepoint (2145) for candidate (676061)!
Timepoint V2 ; SubProjectID: 1 ; Effective DOB: 1980-02-02 ; (SessionID): 2147
Error: failed to get the list of needed instruments for candidate (676061), timepoint (2147):
Error: Cannot diagnose the non-started timepoint (2147) for candidate (676061)!
Timepoint V3 ; SubProjectID: 2 ; Effective DOB: 1980-02-02 ; (SessionID): 2148
Error: failed to get the list of needed instruments for candidate (676061), timepoint (2148):
Error: Cannot diagnose the non-started timepoint (2148) for candidate (676061)!
Timepoint V4 ; SubProjectID: 3 ; Effective DOB: 1980-02-02 ; (SessionID): 2149
Error: failed to get the list of needed instruments for candidate (676061), timepoint (2149):
Error: Cannot diagnose the non-started timepoint (2149) for candidate (676061)!
Timepoint V5 ; SubProjectID: 3 ; Effective DOB: 1980-02-02 ; (SessionID): 2150
Error: failed to get the list of needed instruments for candidate (676061), timepoint (2150):
Error: Cannot diagnose the non-started timepoint (2150) for candidate (676061)!
Timepoint V6 ; SubProjectID: 3 ; Effective DOB: 1980-02-02 ; (SessionID): 2151
Error: failed to get the list of needed instruments for candidate (676061), timepoint (2151):
Error: Cannot diagnose the non-started timepoint (2151) for candidate (676061)!
fix_date
option returns an error (on dob and on visit)
$ php fix_timepoint_date_problems.php fix_date 676061 2020-01-01 dob
PHP Notice: Undefined index: UserID in /var/www/loris/php/libraries/User.class.inc on line 256
PHP Fatal error: Uncaught TypeError: Return value of User::getUsername() must be of the type string, null returned in /var/www/loris/php/libraries/User.class.inc:256
Stack trace:
#0 /var/www/loris/tools/fix_timepoint_date_problems.php(415): User->getUsername()
#1 /var/www/loris/tools/fix_timepoint_date_problems.php(222): fixDate(Object(LORIS\StudyEntities\Candidate\CandID), 'dob', '2020-01-01')
#2 {main}
thrown in /var/www/loris/php/libraries/User.class.inc on line 256
$ php fix_timepoint_date_problems.php fix_date 676061 2020-01-01 V1 2145
PHP Notice: Undefined index: UserID in /var/www/loris/php/libraries/User.class.inc on line 256
PHP Fatal error: Uncaught TypeError: Return value of User::getUsername() must be of the type string, null returned in /var/www/loris/php/libraries/User.class.inc:256
Stack trace:
#0 /var/www/loris/tools/fix_timepoint_date_problems.php(415): User->getUsername()
#1 /var/www/loris/tools/fix_timepoint_date_problems.php(222): fixDate(Object(LORIS\StudyEntities\Candidate\CandID), 'v1', '2020-01-01')
#2 {main}
thrown in /var/www/loris/php/libraries/User.class.inc on line 256
* HELP SCREEN | ||
* display and stop processing if action=help | ||
*/ | ||
if (empty($argv[1]) || $argv[1] == 'help') { |
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.
Exit script after displaying help message if args are missing. Also check that argv[2], [3]..etc are set, otherwise:
PHP Notice: Undefined offset: 1 in /var/www/loris/tools/fix_timepoint_date_problems.php on line 92
PHP Notice: Undefined offset: 2 in /var/www/loris/tools/fix_timepoint_date_problems.php on line 95
PHP Fatal error: Uncaught TypeError: Argument 1 passed to LORIS\StudyEntities\Candidate\ValidatableIdentifier::__construct() must be of the type string, null given, called in /var/www/loris/tools/fix_timepoint_date_problems.php on line 95 and defined in /var/www/loris/src/StudyEntities/Candidate/ValidatableIdentifier.php:58
Stack trace:
#0 /var/www/loris/tools/fix_timepoint_date_problems.php(95): LORIS\StudyEntities\Candidate\ValidatableIdentifier->__construct(NULL)
#1 {main}
thrown in /var/www/loris/src/StudyEntities/Candidate/ValidatableIdentifier.php on line 58
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.
Thank you @jesscall for all you suggestions. I will have a look shortly.
cba2763
to
b5d3089
Compare
b5d3089
to
b7c85df
Compare
b7c85df
to
3196a14
Compare
@jesscall You were right, there were several problems in this script, thanks to have reported them. I made an attempt to fix them, let me know what you think. |
abd6e76
to
b13c8f9
Compare
01583bd
to
305856c
Compare
@driusan What is missing in this PR to be ready? |
The change to the timepoint class still needs to be reverted. |
Blocked by #6825 |
#6825 is merged |
e27475c
to
eec1134
Compare
@driusan Ready to be reviewed/merged. |
eec1134
to
66c8a64
Compare
@driusan Rebased. |
@jesscall GitHub says you requested changes.. can you update your review so I can merge (if you're satisfied..)? |
66c8a64
to
6811979
Compare
Replaces #5984
This PR also makes changes to the User and Timepoint class, to fix return type inaccuracies.
To test
npm run lint:php
php tools/fix_timepoint_date_problems.php