1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-01 03:02:43 +01:00
phorge-phorge/src/applications/people/controller
epriestley 489303a057 Fix transaction handling in PhabricatorUserEditor->createNewUser()
Summary:
See https://github.com/facebook/phabricator/issues/117

  - The $user save can hit a duplicate key exception like the email, but we don't handle it correctly.
  - When the $user saves but the $email does not, the $user is left with a (rolled-back, invalid) ID. This makes the UI glitch out a bit. Wipe the ID if we abort the transaction.
  - We show the "Required" star marker even if the email is filled in.

The ID issue is sort of a general problem, but I think it's fairly rare: you must be doing inserts on related objects and the caller must catch the transaction failure and attempt to handle it in some way.

I can think of three approaches:

  - Manually "roll back" the objects inside the transaction, as here. Seems OK if this really is a rare problem.
  - Automatically roll back the 'id' and 'phid' columns (if they exist). Seems reasonable but maybe more complicated than necessary. Won't get every case right. For instance, if we inserted a third object here and that failed, $email would still have the userPHID set.
  - Automatically roll back the entire object. We can do this by cloning all the writable fields. Seems like it might be way too magical, but maybe the right solution? Might have weird bugs with nonwritable fields and other random stuff.

We can trigger the rollback by storing objects we updated on the transaction, and either throwing them away or rolling them back on saveTransaction() / killTransaction().

These fancier approaches all seem to have some tradeoffs though, and I don't think we need to pick one yet, since this has only caused problems in one case.

Test Plan: Tried to create a new user (via People -> Create New User) with a duplicate username. Got a proper UI message with no exception and no UI glitchiness.

Reviewers: btrahan, vrana, hgrimberg, hgrimberg01

Reviewed By: hgrimberg01

CC: aran

Differential Revision: https://secure.phabricator.com/D2650
2012-06-05 06:46:01 -07:00
..
settings/panels Move files in Phabricator one level up 2012-06-01 12:32:44 -07:00
PhabricatorEmailVerificationController.php Move files in Phabricator one level up 2012-06-01 12:32:44 -07:00
PhabricatorPeopleController.php Move files in Phabricator one level up 2012-06-01 12:32:44 -07:00
PhabricatorPeopleEditController.php Fix transaction handling in PhabricatorUserEditor->createNewUser() 2012-06-05 06:46:01 -07:00
PhabricatorPeopleListController.php Move files in Phabricator one level up 2012-06-01 12:32:44 -07:00
PhabricatorPeopleLogsController.php Move files in Phabricator one level up 2012-06-01 12:32:44 -07:00
PhabricatorPeopleProfileController.php Move files in Phabricator one level up 2012-06-01 12:32:44 -07:00
PhabricatorUserSettingsController.php Move files in Phabricator one level up 2012-06-01 12:32:44 -07:00