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 the avatar files as well as the user meta when deleting a user #797

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions qa-include/db/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ function qa_db_user_delete($userid)
{
qa_db_query_sub('UPDATE ^posts SET lastuserid=NULL WHERE lastuserid=$', $userid);
qa_db_query_sub('DELETE FROM ^userpoints WHERE userid=$', $userid);

// Delete blobs including the files:
require_once QA_INCLUDE_DIR . 'app/blobs.php';

$blobIds = qa_db_read_all_values(qa_db_query_sub('SELECT avatarblobid FROM ^users WHERE userid=$', $userid));
foreach ($blobIds as $blobid)
qa_delete_blob($blobid);

qa_db_query_sub('DELETE FROM ^blobs WHERE blobid=(SELECT avatarblobid FROM ^users WHERE userid=$)', $userid);
qa_db_query_sub('DELETE FROM ^users WHERE userid=$', $userid);

Expand All @@ -92,6 +100,7 @@ function qa_db_user_delete($userid)
qa_db_query_sub('UPDATE ^posts SET userid=NULL WHERE userid=$', $userid);
qa_db_query_sub('DELETE FROM ^userlogins WHERE userid=$', $userid);
qa_db_query_sub('DELETE FROM ^userprofile WHERE userid=$', $userid);
qa_db_query_sub('DELETE FROM ^usermetas WHERE userid=$', $userid);
qa_db_query_sub('DELETE FROM ^userfavorites WHERE userid=$', $userid);
qa_db_query_sub('DELETE FROM ^userevents WHERE userid=$', $userid);
qa_db_query_sub('DELETE FROM ^uservotes WHERE userid=$', $userid);
Expand Down