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

Fix credential control logic for restricted credentials

Summary: Fixes T12975. This logic didn't deal with PolicyException correctly.

Test Plan: {F5167549}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12975

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

+20 -14
+20 -14
src/applications/passphrase/view/PassphraseCredentialControl.php
··· 53 53 if (strlen($current_phid) && empty($options_map[$current_phid])) { 54 54 $viewer = $this->getViewer(); 55 55 56 - $user_credential = id(new PassphraseCredentialQuery()) 57 - ->setViewer($viewer) 58 - ->withPHIDs(array($current_phid)) 59 - ->executeOne(); 60 - if (!$user_credential) { 56 + $current_name = null; 57 + try { 58 + $user_credential = id(new PassphraseCredentialQuery()) 59 + ->setViewer($viewer) 60 + ->withPHIDs(array($current_phid)) 61 + ->executeOne(); 62 + 63 + if ($user_credential) { 64 + $current_name = pht( 65 + '%s %s', 66 + $user_credential->getMonogram(), 67 + $user_credential->getName()); 68 + } 69 + } catch (PhabricatorPolicyException $policy_exception) { 61 70 // Pull the credential with the ominipotent viewer so we can look up 62 - // the ID and tell if it's restricted or invalid. 71 + // the ID and provide the monogram. 63 72 $omnipotent_credential = id(new PassphraseCredentialQuery()) 64 73 ->setViewer(PhabricatorUser::getOmnipotentUser()) 65 74 ->withPHIDs(array($current_phid)) ··· 68 77 $current_name = pht( 69 78 '%s (Restricted Credential)', 70 79 $omnipotent_credential->getMonogram()); 71 - } else { 72 - $current_name = pht( 73 - 'Invalid Credential ("%s")', 74 - $current_phid); 75 80 } 76 - } else { 81 + } 82 + 83 + if ($current_name === null) { 77 84 $current_name = pht( 78 - '%s %s', 79 - $user_credential->getMonogram(), 80 - $user_credential->getName()); 85 + 'Invalid Credential ("%s")', 86 + $current_phid); 81 87 } 82 88 83 89 $options_map = array(