From 59678094fb777aed3c3eb66e8075c082b3dc393f Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Thu, 25 Jul 2024 15:42:14 +0200 Subject: [PATCH] Refactor PhabricatorBadgesEditRecipientsController to remove dead code Summary: `$form` in `$dialog = id(new AphrontDialogView())->appendForm($form)` is only defined when `if ($can_edit)` was `true` beforehand. But that was always true. Thus add a variable definition (and remove some unused variables like `$form_box`). Test Plan: Visit the page /badges/recipients/1/ or also directly /badges/recipients/1/add/ and add some recipients. It still works as before. Visit the page without enough permissions. It does not allow to edit them, as before. Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Differential Revision: https://we.phorge.it/D25744 --- ...bricatorBadgesEditRecipientsController.php | 29 ++++++------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/src/applications/badges/controller/PhabricatorBadgesEditRecipientsController.php b/src/applications/badges/controller/PhabricatorBadgesEditRecipientsController.php index ce437f1a5d..1706b0a644 100644 --- a/src/applications/badges/controller/PhabricatorBadgesEditRecipientsController.php +++ b/src/applications/badges/controller/PhabricatorBadgesEditRecipientsController.php @@ -49,26 +49,15 @@ final class PhabricatorBadgesEditRecipientsController ->setURI($view_uri); } - $can_edit = PhabricatorPolicyFilter::hasCapability( - $viewer, - $badge, - PhabricatorPolicyCapability::CAN_EDIT); - - $form_box = null; - $title = pht('Add Recipient'); - if ($can_edit) { - $header_name = pht('Edit Recipients'); - - $form = new AphrontFormView(); - $form - ->setUser($viewer) - ->setFullWidth(true) - ->appendControl( - id(new AphrontFormTokenizerControl()) - ->setName('phids') - ->setLabel(pht('Recipients')) - ->setDatasource(new PhabricatorPeopleDatasource())); - } + $form = new AphrontFormView(); + $form + ->setUser($viewer) + ->setFullWidth(true) + ->appendControl( + id(new AphrontFormTokenizerControl()) + ->setName('phids') + ->setLabel(pht('Recipients')) + ->setDatasource(new PhabricatorPeopleDatasource())); $dialog = id(new AphrontDialogView()) ->setUser($viewer)