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

Disallow awarding a badge without selecting recipient

Summary:
Do not continue on missing fields (in this case: the badge recipient) in `PhabricatorBadgesEditRecipientsController`.

Closes T15827

Test Plan: See steps in T15827.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15827

Differential Revision: https://we.phorge.it/D25740

+21 -13
+21 -13
src/applications/badges/controller/PhabricatorBadgesEditRecipientsController.php
··· 7 7 $viewer = $request->getViewer(); 8 8 $id = $request->getURIData('id'); 9 9 $xactions = array(); 10 + $errors = array(); 11 + $e_recipient = true; 10 12 11 13 $badge = id(new PhabricatorBadgesQuery()) 12 14 ->setViewer($viewer) ··· 29 31 $add_recipients = $request->getArr('phids'); 30 32 if ($add_recipients) { 31 33 foreach ($add_recipients as $phid) { 32 - $award_phids[] = $phid; 34 + $award_phids[$phid] = $phid; 33 35 } 36 + } else { 37 + $errors[] = pht('Recipient name is required.'); 38 + $e_recipient = pht('Required'); 34 39 } 35 40 36 - $xactions[] = id(new PhabricatorBadgesTransaction()) 37 - ->setTransactionType( 38 - PhabricatorBadgesBadgeAwardTransaction::TRANSACTIONTYPE) 39 - ->setNewValue($award_phids); 41 + if (!$errors) { 42 + $xactions[] = id(new PhabricatorBadgesTransaction()) 43 + ->setTransactionType( 44 + PhabricatorBadgesBadgeAwardTransaction::TRANSACTIONTYPE) 45 + ->setNewValue($award_phids); 40 46 41 - $editor = id(new PhabricatorBadgesEditor()) 42 - ->setActor($viewer) 43 - ->setContentSourceFromRequest($request) 44 - ->setContinueOnNoEffect(true) 45 - ->setContinueOnMissingFields(true) 46 - ->applyTransactions($badge, $xactions); 47 + $editor = id(new PhabricatorBadgesEditor()) 48 + ->setActor($viewer) 49 + ->setContentSourceFromRequest($request) 50 + ->setContinueOnNoEffect(true) 51 + ->setContinueOnMissingFields(true) 52 + ->applyTransactions($badge, $xactions); 47 53 48 - return id(new AphrontRedirectResponse()) 49 - ->setURI($view_uri); 54 + return id(new AphrontRedirectResponse()) 55 + ->setURI($view_uri); 56 + } 50 57 } 51 58 52 59 $form = new AphrontFormView(); ··· 57 64 id(new AphrontFormTokenizerControl()) 58 65 ->setName('phids') 59 66 ->setLabel(pht('Recipients')) 67 + ->setError($e_recipient) 60 68 ->setDatasource(new PhabricatorPeopleDatasource())); 61 69 62 70 $dialog = id(new AphrontDialogView())