-
Notifications
You must be signed in to change notification settings - Fork 237
Open
Labels
Description
The following three database tables need garbage collection, clearing any rows that have been marked as expired:
users_remembered
users_resets
users_throttling
For most use cases, the best solution may be to trigger the garbage collection for a table randomly, e.g. during related operations, using an implementation like this:
function random_float($min = null, $max = null) {
$min = isset($min) && \is_numeric($min) ? (float) $min : 0;
$max = isset($max) && \is_numeric($max) ? (float) $max : 1;
return $min + \mt_rand(0, \mt_getrandmax()) / \mt_getrandmax() * ($max - $min);
}
$probability = 0.02;
if (\random_float() < $probability) {
// perform garbage collection ...
}For the users_confirmations table, garbage collection would be more complex. For each user_id and for each email in that table, the row with the largest id must be preserved so as not to break the re-sending of previous confirmations.