@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.

Update accountadmin to use new admin empowerment code

Summary: Fixes https://discourse.phabricator-community.org/t/admin-account-creation-fails-call-to-undefined-method-phabricatorusereditor-makeadminuser/2227. This callsite got skipped when updating the EmpowerController to use the new transactional admin approval code.

Test Plan: Invoked `accountadmin` to promote a user, no longer got an exception.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D19915

+44 -3
+20 -1
scripts/user/account_admin.php
··· 200 200 $editor->updateUser($user, $verify_email); 201 201 } 202 202 203 - $editor->makeAdminUser($user, $set_admin); 204 203 $editor->makeSystemAgentUser($user, $set_system_agent); 204 + 205 + $xactions = array(); 206 + $xactions[] = id(new PhabricatorUserTransaction()) 207 + ->setTransactionType( 208 + PhabricatorUserEmpowerTransaction::TRANSACTIONTYPE) 209 + ->setNewValue($set_admin); 210 + 211 + $actor = PhabricatorUser::getOmnipotentUser(); 212 + $content_source = PhabricatorContentSource::newForSource( 213 + PhabricatorConsoleContentSource::SOURCECONST); 214 + 215 + $people_application_phid = id(new PhabricatorPeopleApplication())->getPHID(); 216 + 217 + $transaction_editor = id(new PhabricatorUserTransactionEditor()) 218 + ->setActor($actor) 219 + ->setActingAsPHID($people_application_phid) 220 + ->setContentSource($content_source) 221 + ->setContinueOnMissingFields(true); 222 + 223 + $transaction_editor->applyTransactions($user, $xactions); 205 224 206 225 $user->saveTransaction(); 207 226
+20 -1
src/applications/auth/controller/PhabricatorAuthRegisterController.php
··· 416 416 } 417 417 418 418 if ($is_setup) { 419 - $editor->makeAdminUser($user, true); 419 + $xactions = array(); 420 + $xactions[] = id(new PhabricatorUserTransaction()) 421 + ->setTransactionType( 422 + PhabricatorUserEmpowerTransaction::TRANSACTIONTYPE) 423 + ->setNewValue(true); 424 + 425 + $actor = PhabricatorUser::getOmnipotentUser(); 426 + $content_source = PhabricatorContentSource::newFromRequest( 427 + $request); 428 + 429 + $people_application_phid = id(new PhabricatorPeopleApplication()) 430 + ->getPHID(); 431 + 432 + $transaction_editor = id(new PhabricatorUserTransactionEditor()) 433 + ->setActor($actor) 434 + ->setActingAsPHID($people_application_phid) 435 + ->setContentSource($content_source) 436 + ->setContinueOnMissingFields(true); 437 + 438 + $transaction_editor->applyTransactions($user, $xactions); 420 439 } 421 440 422 441 $account->setUserPHID($user->getPHID());
+4 -1
src/applications/people/xaction/PhabricatorUserEmpowerTransaction.php
··· 45 45 'status as an administrator.'), $xaction); 46 46 } 47 47 48 - if (!$actor->getIsAdmin()) { 48 + $is_admin = $actor->getIsAdmin(); 49 + $is_omnipotent = $actor->isOmnipotent(); 50 + 51 + if (!$is_admin && !$is_omnipotent) { 49 52 $errors[] = $this->newInvalidError( 50 53 pht('You must be an administrator to create administrators.'), 51 54 $xaction);