aces / Loris

LORIS is a web-accessible database solution for longitudinal multi-site studies.
GNU General Public License v3.0
145 stars 173 forks source link

[DQT] CouchDB_Confirm_Integrity.php not deleting CouchDB docs pertaining to deleted LORIS candidates #6566

Open ejoh1101 opened 4 years ago

ejoh1101 commented 4 years ago

Describe the bug CouchDB_Confirm_Integrity.php does not delete docs related to candidates deleted from LORIS DB.

To Reproduce Delete a candidate using delete_candidate.php (or manually delete from candidate table in MySQL DB). Run CouchDB_Confirm_Integrity.php. Note that CouchDB docs related to deleted candidate will appear in log with text "Nothing wrong with ". Using DQT this deleted candidate is still queryable.

What did you expect to happen? Expected CouchDB_Confirm_Integrity.php to remove documents from CouchDB that no longer match a participant in LORIS database.

Server Environment:

Additional context It appears that there is no condition in CouchDB_Confirm_Integrity.php function run() that would apply if $sqlDB returns empty. All if conditions only apply if !empty($sqlDB) so when $sqlDB is returned empty it defaults to the else statement ("Nothing wrong"). I'd suggest adding a condition for when $sqlDB returns empty, something along the lines of

} else if (empty($sqlDB)) {   print "PSCID $pscid no longer exists for $row[id].\n";   $this->CouchDB->deleteDoc($row['id']);

I realize that deleting candidates is not a suggested method for removing data from LORIS but there are cases where it is appropriate. In these cases, it would make sense that CouchDB_Confirm_Integrity.php would remove these docs (thus confirming the integrity of the CouchDB data).

christinerogers commented 4 years ago

thanks for reporting this, @ejoh1101

@samirdas @driusan @ridz1208 is this DQT delete-cascade feature something @maltheism might integrate into the next DQT updates / Roadmap ?

ridz1208 commented 2 years ago

@driusan this might even be critical?

cmadjar commented 1 year ago

@zaliqarosli can you look into it? (from Dave and Rida ;))

zaliqarosli commented 1 year ago

hi ! i believe this was targeted by https://github.com/aces/Loris/pull/8148 @cmadjar @ridz1208 @driusan