All this is correctly taken care of by the database.

This fixes several bugs where records should be deleted instead of
NULLified. For example, when a comment deleter's account was deleted,
DelUsersID of the comment was (re)set to NULL, causing the comment to
appear again.

Signed-off-by: Marcel Korpel <[email protected]>
---
 web/lib/acctfuncs.inc.php | 33 ---------------------------------
 1 file changed, 33 deletions(-)

diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php
index edd38ee..e3cba37 100644
--- a/web/lib/acctfuncs.inc.php
+++ b/web/lib/acctfuncs.inc.php
@@ -927,39 +927,6 @@ function user_delete($id) {
        $dbh = DB::connect();
        $id = intval($id);
 
-       /*
-        * These are normally already taken care of by propagation constraints
-        * but it is better to be explicit here.
-        */
-       $fields_delete = array(
-               array("Sessions", "UsersID"),
-               array("PackageVotes", "UsersID"),
-               array("CommentNotify", "UsersID")
-       );
-
-       $fields_set_null = array(
-               array("PackageBases", "SubmitterUID"),
-               array("PackageBases", "MaintainerUID"),
-               array("PackageBases", "SubmitterUID"),
-               array("PackageComments", "UsersID"),
-               array("PackageComments", "DelUsersID"),
-               array("PackageRequests", "UsersID"),
-               array("TU_VoteInfo", "SubmitterID"),
-               array("TU_Votes", "UserID")
-       );
-
-       foreach($fields_delete as list($table, $field)) {
-               $q = "DELETE FROM " . $table . " ";
-               $q.= "WHERE " . $field . " = " . $id;
-               $dbh->query($q);
-       }
-
-       foreach($fields_set_null as list($table, $field)) {
-               $q = "UPDATE " . $table . " SET " . $field . " = NULL ";
-               $q.= "WHERE " . $field . " = " . $id;
-               $dbh->query($q);
-       }
-
        $q = "DELETE FROM Users WHERE ID = " . $id;
        $dbh->query($q);
        return;
-- 
2.4.5

Reply via email to