Merge lp:~vasilev/psiphon/sprint3-457431 into lp:psiphon
Proposed by
Robert Vasilev
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Adam Kruger | ||||
Approved revision: | 123 | ||||
Merged at revision: | 126 | ||||
Proposed branch: | lp:~vasilev/psiphon/sprint3-457431 | ||||
Merge into: | lp:psiphon | ||||
Diff against target: |
193 lines (+143/-2) 4 files modified
trunk/cronjobs/cleanup_unused_accounts_cron.php (+95/-0) trunk/cronjobs/crontab (+1/-1) trunk/www/config.php (+12/-0) trunk/www/includes/database_helpers.php (+35/-1) |
||||
To merge this branch: | bzr merge lp:~vasilev/psiphon/sprint3-457431 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Adam Kruger | Approve | ||
Rod | Pending | ||
Review via email: mp+35397@code.launchpad.net |
This proposal supersedes a proposal from 2010-08-31.
Description of the change
Fixes for https:/
1. Added cleanup_
2. Added 3 configuration directives in config.php (inactivity periods for non-disabled and disabled users, and affected user classes list).
3. Updated crontab sample to invoke cleanup_
Upd:
Rod's comments have been implemented.
To post a comment you must log in.
1. Should not hard code user class numbers:
$config[ "unused_ account_ cleanup_ affected_ user_classes" ] = array(2, 3, 4, 6, 7);
In includes/ user_class_ helpers. php, we have helper functions like get_power_ user_class_ id().
2. If the series of DELETE statements in delete_ user_and_ related_ data fails in the middle (e.g., server crash) then we could be left with bookmark, invite, userproxy, etc. referring to non-existing user. This is probably bad.
Recommend doing "DELETE FROM user" last instead of first to minimize the risk of inconsistency in the database (we can't guarantee consistency with the MyISAM engine which lacks transactions)/
3. It appears that the SQL works like this:
php array = SELECT userid WHERE ...
DELETE WHERE id in (php array rendered as string) [repeat 6 times]
We recommend this pattern instead:
DELETE WHERE id in (SELECT userid WHERE ...) [repeat 6 times]
Reasoning: there is far less data sent between PHP and the database engine in the second approach; we don't know how big the user id list could be; MySQL ought to cache the results of the SELECT so redoing it in each DELETE should not incur full overhead.