@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+23
+2
src/__phutil_library_map__.php
··· 1055 1055 'PasteMockMailReceiver' => 'applications/paste/mail/PasteMockMailReceiver.php', 1056 1056 'PasteReplyHandler' => 'applications/paste/mail/PasteReplyHandler.php', 1057 1057 'PeopleCapabilityBrowseUserDirectory' => 'applications/people/capability/PeopleCapabilityBrowseUserDirectory.php', 1058 + 'PeopleUserLogGarbageCollector' => 'applications/people/garbagecollector/PeopleUserLogGarbageCollector.php', 1058 1059 'Phabricator404Controller' => 'applications/base/controller/Phabricator404Controller.php', 1059 1060 'PhabricatorAWSConfigOptions' => 'applications/config/option/PhabricatorAWSConfigOptions.php', 1060 1061 'PhabricatorAccessControlTestCase' => 'applications/base/controller/__tests__/PhabricatorAccessControlTestCase.php', ··· 3665 3666 'PasteMockMailReceiver' => 'PhabricatorObjectMailReceiver', 3666 3667 'PasteReplyHandler' => 'PhabricatorMailReplyHandler', 3667 3668 'PeopleCapabilityBrowseUserDirectory' => 'PhabricatorPolicyCapability', 3669 + 'PeopleUserLogGarbageCollector' => 'PhabricatorGarbageCollector', 3668 3670 'Phabricator404Controller' => 'PhabricatorController', 3669 3671 'PhabricatorAWSConfigOptions' => 'PhabricatorApplicationConfigOptions', 3670 3672 'PhabricatorAccessControlTestCase' => 'PhabricatorTestCase',
+21
src/applications/people/garbagecollector/PeopleUserLogGarbageCollector.php
··· 1 + <?php 2 + 3 + final class PeopleUserLogGarbageCollector 4 + extends PhabricatorGarbageCollector { 5 + 6 + public function collectGarbage() { 7 + $ttl = phutil_units('180 days in seconds'); 8 + 9 + $table = new PhabricatorUserLog(); 10 + $conn_w = $table->establishConnection('w'); 11 + 12 + queryfx( 13 + $conn_w, 14 + 'DELETE FROM %T WHERE dateCreated < %d LIMIT 100', 15 + $table->getTableName(), 16 + time() - $ttl); 17 + 18 + return ($conn_w->getAffectedRows() == 100); 19 + } 20 + 21 + }