From 39d415e90eb3111c04cadee78045048bf3c4ec03 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 13 Aug 2018 14:05:47 -0700 Subject: [PATCH] Move users to modular transactions Summary: Ref T13164. See PHI642. I'd like to provide a third-generation `user.edit` API endpoint and make `user.enable` and `user.disable` obsolete before meddling with policy details, even if it isn't full-fledged yet. Users do already have a transactions table and a Transaction-based editor, but it's only used for editing title, real name, etc. All of these are custom fields, so their support comes in automatically through CustomField extension code. Realign it for modular transactions so new code will be fully modern. There are no actual standalone transaction types yet so this diff is pretty thin. Test Plan: - Grepped for `UserProfileEditor`. - Edited a user's title/real name/icon. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13164 Differential Revision: https://secure.phabricator.com/D19576 --- src/__phutil_library_map__.php | 8 +++++--- .../controller/PhabricatorPeopleProfileEditController.php | 5 ++--- ...ileEditor.php => PhabricatorUserTransactionEditor.php} | 5 ++--- src/applications/people/storage/PhabricatorUser.php | 2 +- .../people/storage/PhabricatorUserTransaction.php | 6 +++++- .../people/xaction/PhabricatorUserTransactionType.php | 4 ++++ 6 files changed, 19 insertions(+), 11 deletions(-) rename src/applications/people/editor/{PhabricatorUserProfileEditor.php => PhabricatorUserTransactionEditor.php} (73%) create mode 100644 src/applications/people/xaction/PhabricatorUserTransactionType.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index bd4cfef6c2..47ea4e8bf1 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -4583,7 +4583,6 @@ phutil_register_library_map(array( 'PhabricatorUserPreferencesTransaction' => 'applications/settings/storage/PhabricatorUserPreferencesTransaction.php', 'PhabricatorUserPreferencesTransactionQuery' => 'applications/settings/query/PhabricatorUserPreferencesTransactionQuery.php', 'PhabricatorUserProfile' => 'applications/people/storage/PhabricatorUserProfile.php', - 'PhabricatorUserProfileEditor' => 'applications/people/editor/PhabricatorUserProfileEditor.php', 'PhabricatorUserProfileImageCacheType' => 'applications/people/cache/PhabricatorUserProfileImageCacheType.php', 'PhabricatorUserRealNameField' => 'applications/people/customfield/PhabricatorUserRealNameField.php', 'PhabricatorUserRolesField' => 'applications/people/customfield/PhabricatorUserRolesField.php', @@ -4593,6 +4592,8 @@ phutil_register_library_map(array( 'PhabricatorUserTestCase' => 'applications/people/storage/__tests__/PhabricatorUserTestCase.php', 'PhabricatorUserTitleField' => 'applications/people/customfield/PhabricatorUserTitleField.php', 'PhabricatorUserTransaction' => 'applications/people/storage/PhabricatorUserTransaction.php', + 'PhabricatorUserTransactionEditor' => 'applications/people/editor/PhabricatorUserTransactionEditor.php', + 'PhabricatorUserTransactionType' => 'applications/people/xaction/PhabricatorUserTransactionType.php', 'PhabricatorUsersEditField' => 'applications/transactions/editfield/PhabricatorUsersEditField.php', 'PhabricatorUsersPolicyRule' => 'applications/people/policyrule/PhabricatorUsersPolicyRule.php', 'PhabricatorUsersSearchField' => 'applications/people/searchfield/PhabricatorUsersSearchField.php', @@ -10575,7 +10576,6 @@ phutil_register_library_map(array( 'PhabricatorUserPreferencesTransaction' => 'PhabricatorApplicationTransaction', 'PhabricatorUserPreferencesTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'PhabricatorUserProfile' => 'PhabricatorUserDAO', - 'PhabricatorUserProfileEditor' => 'PhabricatorApplicationTransactionEditor', 'PhabricatorUserProfileImageCacheType' => 'PhabricatorUserCacheType', 'PhabricatorUserRealNameField' => 'PhabricatorUserCustomField', 'PhabricatorUserRolesField' => 'PhabricatorUserCustomField', @@ -10584,7 +10584,9 @@ phutil_register_library_map(array( 'PhabricatorUserStatusField' => 'PhabricatorUserCustomField', 'PhabricatorUserTestCase' => 'PhabricatorTestCase', 'PhabricatorUserTitleField' => 'PhabricatorUserCustomField', - 'PhabricatorUserTransaction' => 'PhabricatorApplicationTransaction', + 'PhabricatorUserTransaction' => 'PhabricatorModularTransaction', + 'PhabricatorUserTransactionEditor' => 'PhabricatorApplicationTransactionEditor', + 'PhabricatorUserTransactionType' => 'PhabricatorModularTransactionType', 'PhabricatorUsersEditField' => 'PhabricatorTokenizerEditField', 'PhabricatorUsersPolicyRule' => 'PhabricatorPolicyRule', 'PhabricatorUsersSearchField' => 'PhabricatorSearchTokenizerField', diff --git a/src/applications/people/controller/PhabricatorPeopleProfileEditController.php b/src/applications/people/controller/PhabricatorPeopleProfileEditController.php index 3eda8a968b..4876f4495d 100644 --- a/src/applications/people/controller/PhabricatorPeopleProfileEditController.php +++ b/src/applications/people/controller/PhabricatorPeopleProfileEditController.php @@ -38,10 +38,9 @@ final class PhabricatorPeopleProfileEditController new PhabricatorUserTransaction(), $request); - $editor = id(new PhabricatorUserProfileEditor()) + $editor = id(new PhabricatorUserTransactionEditor()) ->setActor($viewer) - ->setContentSource( - PhabricatorContentSource::newFromRequest($request)) + ->setContentSourceFromRequest($request) ->setContinueOnNoEffect(true); try { diff --git a/src/applications/people/editor/PhabricatorUserProfileEditor.php b/src/applications/people/editor/PhabricatorUserTransactionEditor.php similarity index 73% rename from src/applications/people/editor/PhabricatorUserProfileEditor.php rename to src/applications/people/editor/PhabricatorUserTransactionEditor.php index 9ec02ba2af..c0dfa941af 100644 --- a/src/applications/people/editor/PhabricatorUserProfileEditor.php +++ b/src/applications/people/editor/PhabricatorUserTransactionEditor.php @@ -1,6 +1,6 @@