Skip to content
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] Tool failures #9611

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

skarya22
Copy link
Contributor

@skarya22 skarya22 commented Feb 21, 2025

Brief summary of changes

  • These tools had multiple broken parts. Mostly related to CandidateID changes, but also others
image

Closes #9629
Closes #9631
Closes #9633

Testing instructions (if applicable)

  1. Try running the scripts

@skarya22 skarya22 added the 27.0.0 - Bugs Bugs Found in LORIS 27 testing label Feb 21, 2025
@skarya22 skarya22 added this to the 27.0.0 milestone Feb 21, 2025
@skarya22 skarya22 changed the title [tools] data_integrity_check fails [tools] Tool failures Feb 21, 2025
@driusan
Copy link
Collaborator

driusan commented Feb 24, 2025

@jeffersoncasimir these seem to be mostly the CandID changes (with 1 or 2 lorisInstance ones).

Can you review?

@driusan
Copy link
Collaborator

driusan commented Feb 24, 2025

@skarya22 PHPCS is failing.



FILE: /home/runner/work/Loris/Loris/tools/detect_conflicts.php
--------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
--------------------------------------------------------------------------------
 573 | ERROR | Doc comment for parameter "$lorisInstance" missing
 577 | ERROR | Doc comment for parameter $instruments does not match actual
     |       | variable name $lorisInstance
 578 | ERROR | Doc comment for parameter $confirm does not match actual
     |       | variable name $instruments
--------------------------------------------------------------------------------

@jeffersoncasimir
Copy link
Contributor

jeffersoncasimir commented Feb 24, 2025

@skarya22 This PR appears to be based on 26.0-release instead of main. Not necessarily problematic but may not accurately reflect the state to be tested

@skarya22 skarya22 added the State: Needs work PR awaiting additional work by the author to proceed label Feb 25, 2025
@skarya22 skarya22 removed the State: Needs work PR awaiting additional work by the author to proceed label Feb 25, 2025
Copy link
Contributor

@jeffersoncasimir jeffersoncasimir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, none of these errors seem caused by these changes, but this PR is shining a light on many existing issues.

All scripts were tested with valid inputs with each of their different forks (ex: tosql, confirm). They were not tested with "invalid inputs" (ex: non-existing IDs). Non-mentions can be assumed to be tested and functional (no fatal errors).

I ran tools/data_integrity/data_deletion/delete_candidate.php with confirm and got the following error:

Dropping all DB entries for candidate CandID: 648507 And PSCID: DRV0005
PHP Fatal error:  Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`jcasimir_test_26`.`dataquery_run_results`, CONSTRAINT `dataquery_run_results_ibfk_1` FOREIGN KEY (`CandidateID`) REFERENCES `candidate` (`ID`)) in /var/www/Loris/php/libraries/Database.class.inc:630
Stack trace:
#0 /var/www/Loris/php/libraries/Database.class.inc(630): PDO->exec()
#1 /var/www/Loris/tools/data_integrity/data_deletion/delete_candidate.php(367): Database->delete()
#2 /var/www/Loris/tools/data_integrity/data_deletion/delete_candidate.php(118): deleteCandidate()
#3 {main}
  thrown in /var/www/Loris/php/libraries/Database.class.inc on line 630

I ran tools/data_integrity/data_deletion/delete_timepoint.php with tosql and got the following error:

PHP Fatal error:  Uncaught TypeError: fwrite(): Argument #1 ($stream) must be of type resource, bool given in /var/www/Loris/tools/data_integrity/data_deletion/delete_timepoint.php:503
Stack trace:
#0 /var/www/Loris/tools/data_integrity/data_deletion/delete_timepoint.php(503): fwrite()
#1 /var/www/Loris/tools/data_integrity/data_deletion/delete_timepoint.php(460): _exportSQL()
#2 /var/www/Loris/tools/data_integrity/data_deletion/delete_timepoint.php(120): deleteTimepoint()
#3 {main}
  thrown in /var/www/Loris/tools/data_integrity/data_deletion/delete_timepoint.php on line 503

I ran tools/data_integrity/data_deletion/delete_timepoint.php with confirm and got the following error:

PHP Fatal error:  Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`jcasimir_test_26`.`physiological_file`, CONSTRAINT `FK_session_ID` FOREIGN KEY (`SessionID`) REFERENCES `session` (`ID`)) in /var/www/Loris/php/libraries/Database.class.inc:630
Stack trace:
#0 /var/www/Loris/php/libraries/Database.class.inc(630): PDO->exec()
#1 /var/www/Loris/tools/data_integrity/data_deletion/delete_timepoint.php(365): Database->delete()
#2 /var/www/Loris/tools/data_integrity/data_deletion/delete_timepoint.php(120): deleteTimepoint()
#3 {main}
  thrown in /var/www/Loris/php/libraries/Database.class.inc on line 630

tools/detect_conflicts.php has this error, when used with -i:

PHP Fatal error:  Uncaught TypeError: getCurrentUnresolvedConflicts(): Return value must be of type array, LORIS\Database\Query returned in /var/www/Loris/tools/detect_conflicts.php:358
Stack trace:
#0 /var/www/Loris/tools/detect_conflicts.php(190): getCurrentUnresolvedConflicts()
#1 {main}
  thrown in /var/www/Loris/tools/detect_conflicts.php on line 358

detect_duplicated_commentids.php has an error, similar to the previous:

PHP Fatal error:  Uncaught Error: Cannot use object of type LORIS\Database\Query as array in /var/www/Loris/tools/detect_duplicated_commentids.php:199
Stack trace:
#0 /var/www/Loris/tools/detect_duplicated_commentids.php(127): getCommentIDs()
#1 {main}
  thrown in /var/www/Loris/tools/detect_duplicated_commentids.php on line 199

Not sure what to make of this: php fix_timepoint_date_problems.php add_instrument 300001 1 aosi

Error: failed to add the instrument aosi for timepoint (1):
Error: Database user named lorisadmin does not exist. Please create and then retry script

I otherwise approve of the code changes.

@skarya22
Copy link
Contributor Author

skarya22 commented Mar 5, 2025

@jeffersoncasimir Thank you for catching those! Resolved them

Copy link
Contributor

@jeffersoncasimir jeffersoncasimir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran tools/data_integrity/data_deletion/delete_candidate.php with tosql and got the following error:

PHP Fatal error:  Uncaught TypeError: preg_match_all(): Argument #2 ($subject) must be of type string, array given in /var/www/Loris/tools/data_integrity/data_deletion/delete_candidate.php:201

I ran tools/data_integrity/data_deletion/delete_candidate.php with confirm and got the following error:

PHP Fatal error:  Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`jcasimir_test_26`.`physiological_event_file`, CONSTRAINT `FK_physio_file_ID` FOREIGN KEY (`PhysiologicalFileID`) REFERENCES `physiological_file` (`PhysiologicalFileID`)) in /var/www/Loris/php/libraries/Database.class.inc:630

I ran tools/data_integrity/data_deletion/delete_timepoint.php with confirm and got the following error (same as delete_candidate right above -- tosql is now functional):

PHP Fatal error:  Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`jcasimir_test_26`.`physiological_event_file`, CONSTRAINT `FK_physio_file_ID` FOREIGN KEY (`PhysiologicalFileID`) REFERENCES `physiological_file` (`PhysiologicalFileID`)) in /var/www/Loris/php/libraries/Database.class.inc:630

I am struggling to test tools/detect_conflicts.php in a meaningful way. The previous error is gone, but I can't get it to work with any instrument; it always results in: the instrument is not set or there are no commentids. When I do -i all it will fail at this error that will be addressed by another PR:

PHP Fatal error:  Uncaught OutOfBoundsException: Invalid field Examiner for instrument bmi in /var/www/Loris/php/libraries/NDB_BVL_Instrument.class.inc:1412

I ran tools/detect_duplicated_commentids.php and got the following error:

PHP Fatal error:  Uncaught DomainException: Attempt to use pselectRow on a query that returns multiple rows in /var/www/Loris/php/libraries/Database.class.inc:848

tools/fix_timepoint_date_problems.php appears to work as expected!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
27.0.0 - Bugs Bugs Found in LORIS 27 testing
Projects
None yet
3 participants