Changeset View
Changeset View
Standalone View
Standalone View
src/applications/passphrase/view/PassphraseCredentialControl.php
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | foreach ($this->options as $option) { | ||||
$option->getMonogram(), | $option->getMonogram(), | ||||
$option->getName()); | $option->getName()); | ||||
} | } | ||||
// The user editing the form may not have permission to see the current | // The user editing the form may not have permission to see the current | ||||
// credential. Populate it into the menu to allow them to save the form | // credential. Populate it into the menu to allow them to save the form | ||||
// without making any changes. | // without making any changes. | ||||
$current_phid = $this->getValue(); | $current_phid = $this->getValue(); | ||||
if (strlen($current_phid) && empty($options_map[$current_phid])) { | if (phutil_nonempty_string($current_phid) && | ||||
valerio.bozzolan: I wonder why in the original version they have not used just:
```lang=php
if (!$current_phid… | |||||
empty($options_map[$current_phid])) { | |||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$current_name = null; | $current_name = null; | ||||
try { | try { | ||||
$user_credential = id(new PassphraseCredentialQuery()) | $user_credential = id(new PassphraseCredentialQuery()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withPHIDs(array($current_phid)) | ->withPHIDs(array($current_phid)) | ||||
->executeOne(); | ->executeOne(); | ||||
▲ Show 20 Lines • Show All 146 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0
I wonder why in the original version they have not used just:
As far as I know, this would be the most reliable, readable and minimal check, without any PHP8.1 pitfall.
@avivey do you somehow agree?