mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-20 13:52:40 +01:00
Add a GC for user logs
Summary: Fixes T4368. This is the last "obvious" table we have which we should be GC'ing but do not. It's about 1/12th of the data on `secure.phabricator.com`. This table stores logins, account creation, password resets, login attempts, etc, and is primarily useful if something sketchy happens so you can go back and review login activity. This data is not useful indefinitely, and there's no reason to retain it forever. Because you don't always know when something sketchy happened I've given this table a fairly long TTL (180 days), but we don't need limitless amounts of this data. Test Plan: Ran `phd debug garbage` and saw a reasonable amount of data get GC'd. This table already has an appropriate key. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T4368 Differential Revision: https://secure.phabricator.com/D8128
This commit is contained in:
parent
88436349b8
commit
5a9a96735d
2 changed files with 23 additions and 0 deletions
|
@ -1055,6 +1055,7 @@ phutil_register_library_map(array(
|
|||
'PasteMockMailReceiver' => 'applications/paste/mail/PasteMockMailReceiver.php',
|
||||
'PasteReplyHandler' => 'applications/paste/mail/PasteReplyHandler.php',
|
||||
'PeopleCapabilityBrowseUserDirectory' => 'applications/people/capability/PeopleCapabilityBrowseUserDirectory.php',
|
||||
'PeopleUserLogGarbageCollector' => 'applications/people/garbagecollector/PeopleUserLogGarbageCollector.php',
|
||||
'Phabricator404Controller' => 'applications/base/controller/Phabricator404Controller.php',
|
||||
'PhabricatorAWSConfigOptions' => 'applications/config/option/PhabricatorAWSConfigOptions.php',
|
||||
'PhabricatorAccessControlTestCase' => 'applications/base/controller/__tests__/PhabricatorAccessControlTestCase.php',
|
||||
|
@ -3665,6 +3666,7 @@ phutil_register_library_map(array(
|
|||
'PasteMockMailReceiver' => 'PhabricatorObjectMailReceiver',
|
||||
'PasteReplyHandler' => 'PhabricatorMailReplyHandler',
|
||||
'PeopleCapabilityBrowseUserDirectory' => 'PhabricatorPolicyCapability',
|
||||
'PeopleUserLogGarbageCollector' => 'PhabricatorGarbageCollector',
|
||||
'Phabricator404Controller' => 'PhabricatorController',
|
||||
'PhabricatorAWSConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
||||
'PhabricatorAccessControlTestCase' => 'PhabricatorTestCase',
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
final class PeopleUserLogGarbageCollector
|
||||
extends PhabricatorGarbageCollector {
|
||||
|
||||
public function collectGarbage() {
|
||||
$ttl = phutil_units('180 days in seconds');
|
||||
|
||||
$table = new PhabricatorUserLog();
|
||||
$conn_w = $table->establishConnection('w');
|
||||
|
||||
queryfx(
|
||||
$conn_w,
|
||||
'DELETE FROM %T WHERE dateCreated < %d LIMIT 100',
|
||||
$table->getTableName(),
|
||||
time() - $ttl);
|
||||
|
||||
return ($conn_w->getAffectedRows() == 100);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue