Skip to content

Commit

Permalink
clean up data of disabled users; updates #724
Browse files Browse the repository at this point in the history
  • Loading branch information
following5 committed Jun 25, 2015
1 parent 04c3b3c commit f323b09
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions bin/dbsv-update.php
Expand Up @@ -468,6 +468,12 @@ function dbv_125() // update cache lists implementation; preparation of XML int
update_triggers(); // runs maintain-125.inc.php
}

function dbv_126() // clean up data of disabled accounts
{
sql("DELETE FROM `cache_adoption` WHERE `user_id` IN (SELECT `user_id` FROM `user` WHERE `is_active_flag`=0)");
sql("DELETE FROM `cache_ignore` WHERE `user_id` IN (SELECT `user_id` FROM `user` WHERE `is_active_flag`=0)");
sql("DELETE FROM `cache_watches` WHERE `user_id` IN (SELECT `user_id` FROM `user` WHERE `is_active_flag`=0)");
}

// When adding new mutations, take care that they behave well if run multiple
// times. This improves robustness of database versioning.
Expand Down
8 changes: 6 additions & 2 deletions htdocs/lib2/logic/user.class.php
Expand Up @@ -761,8 +761,12 @@ function disable()
sql("DELETE FROM `user_options` WHERE `user_id`='&1'", $this->nUserId);
$this->reload();

sql("DELETE FROM `cache_lists` WHERE `user_id`='&1'", $this->nUserId);
// Triggers will do all the dependent clean-up.
sql("DELETE FROM `cache_lists` WHERE `user_id`='&1'", $this->nUserId); // Triggers will do all the dependent clean-up.
sql("DELETE FROM `cache_adoption` WHERE `user_id`='&1'", $this->nUserId);
sql("DELETE FROM `cache_ignore` WHERE `user_id`='&1'", $this->nUserId);
sql("DELETE FROM `cache_watches` WHERE `user_id`='&1'", $this->nUserId);
sql("DELETE FROM `watches_waiting` WHERE `user_id`='&1'", $this->nUserId);
sql("DELETE FROM `notify_waiting` WHERE `user_id`='&1'", $this->nUserId);

// lock the user's caches
$error = false;
Expand Down

0 comments on commit f323b09

Please sign in to comment.