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

delete_data_for_users fix #31

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

james-cnz
Copy link
Contributor

I think there is a small error in the function mod_mediagallery\privacy\provider::delete_data_for_users() .

@aolley
Copy link
Collaborator

aolley commented Sep 18, 2023

So this is certainly a bug, but your fix isn't correct.

In delete_data_for_users we only want to delete data belonging to the listed users. Your change indiscriminately deletes the galleries - regardless of if they belonged to one of the users in $userlist.

The original code is obviously broken too. What it needs to do instead is include userid $insql in its select so we only delete galleries in the collection that belong to one of the chosen users.

@james-cnz
Copy link
Contributor Author

james-cnz commented Sep 18, 2023

OK, I think I get it now. Reading over the code again, though, I think there might be another bug. $itemidsql selects items with the relevant user IDs, but not items in galleries with the relevant user IDs. Is this an issue, or does cascading deletes take care of this? (I suspect not?) Either way, the line that deletes from the mediagallery_item DB table only deletes items in galleries with with the relevant user IDs, I think? [EDIT: Not items with the relevant user IDs themselves.]

@james-cnz
Copy link
Contributor Author

It doesn't look like there's cascading deletes to take care of things. And I think the new issue also applies to delete_data_for_user(). I've had another go at it. Not sure how to delete comments made on an image that isn't a specified user's but is in a specified user's gallery, though. If you accept it, it would probably be good to squash merge it, to avoid having the faulty fix in the commit history.

@james-cnz
Copy link
Contributor Author

Oh, looks like there's a function \core_comment\privacy\provider::delete_comments_for_all_users_select() that could be useful. I might look at this tomorrow.

@james-cnz james-cnz mentioned this pull request Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants