From fd5dcc9cfa321e6077eca9c911dd4cb3ec8bb7cf Mon Sep 17 00:00:00 2001 From: Bertrand Gorge Date: Thu, 24 Oct 2019 17:41:12 +0200 Subject: [PATCH 1/2] Delete the avatar files as well as the user meta when deleting a user Fixes issue #779 --- qa-include/db/users.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/qa-include/db/users.php b/qa-include/db/users.php index a8ddcd8fe..f2300a4af 100644 --- a/qa-include/db/users.php +++ b/qa-include/db/users.php @@ -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); @@ -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); From 3cac2d8fb42c8cf7d19517d49efcc2f4f3fc87a5 Mon Sep 17 00:00:00 2001 From: Bertrand Gorge Date: Wed, 19 Feb 2020 12:19:28 +0100 Subject: [PATCH 2/2] Fixed a warning from phpCS --- qa-include/db/users.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qa-include/db/users.php b/qa-include/db/users.php index f2300a4af..649f5625e 100644 --- a/qa-include/db/users.php +++ b/qa-include/db/users.php @@ -87,7 +87,7 @@ function qa_db_user_delete($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)); + $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);