Differential D25184 Diff 664 src/applications/dashboard/install/PhabricatorDashboardObjectInstallWorkflow.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/dashboard/install/PhabricatorDashboardObjectInstallWorkflow.php
Show All 11 Lines | public function handleRequest(AphrontRequest $request) { | ||||
$target_identifier = null; | $target_identifier = null; | ||||
$target_tokens = $request->getArr('target'); | $target_tokens = $request->getArr('target'); | ||||
if ($target_tokens) { | if ($target_tokens) { | ||||
$target_identifier = head($target_tokens); | $target_identifier = head($target_tokens); | ||||
} | } | ||||
if (!strlen($target_identifier)) { | if (!phutil_nonempty_string($target_identifier)) { | ||||
valerio.bozzolan: ✅ I verified the above line
The input string is supposed to be a string, or null.
The… | |||||
$target_identifier = $request->getStr('target'); | $target_identifier = $request->getStr('target'); | ||||
} | } | ||||
if (!strlen($target_identifier)) { | if (!phutil_nonempty_string($target_identifier)) { | ||||
Done Inline Actions✅ Same as above Also note that Aphront#getStr() always return a string, or null. valerio.bozzolan: ✅ Same as above
Also note that `Aphront#getStr()` always return a string, or null. | |||||
$target_identifier = $this->getMode(); | $target_identifier = $this->getMode(); | ||||
} | } | ||||
$target = null; | $target = null; | ||||
if (strlen($target_identifier)) { | if (phutil_nonempty_string($target_identifier)) { | ||||
Done Inline Actions✅ Same as above Note that getMode() is populated from $request->getURIData('modeKey') that should return a string and defaults to null. valerio.bozzolan: ✅ Same as above
Note that `getMode()` is populated from `$request->getURIData('modeKey')` that… | |||||
$targets = array(); | $targets = array(); | ||||
if (ctype_digit($target_identifier)) { | if (ctype_digit($target_identifier)) { | ||||
Not Done Inline Actions✅ Note that ctype_digit() is supposed to accept a string valerio.bozzolan: ✅ Note that `ctype_digit()` is supposed to accept a string | |||||
$targets = $this->newQuery() | $targets = $this->newQuery() | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withIDs(array((int)$target_identifier)) | ->withIDs(array((int)$target_identifier)) | ||||
->execute(); | ->execute(); | ||||
} | } | ||||
if (!$targets) { | if (!$targets) { | ||||
$targets = $this->newQuery() | $targets = $this->newQuery() | ||||
Show All 28 Lines | if ($request->isFormPost() && $target && $can_edit) { | ||||
} else { | } else { | ||||
return $this->newConfirmDialog($target) | return $this->newConfirmDialog($target) | ||||
->addHiddenInput('confirm', 1) | ->addHiddenInput('confirm', 1) | ||||
->addHiddenInput('target', $target_phid); | ->addHiddenInput('target', $target_phid); | ||||
} | } | ||||
} | } | ||||
$errors = array(); | $errors = array(); | ||||
if (strlen($target_identifier)) { | if (phutil_nonempty_string($target_identifier)) { | ||||
Not Done Inline Actions✅ Same as above valerio.bozzolan: ✅ Same as above | |||||
if (!$target) { | if (!$target) { | ||||
$errors[] = pht('Choose a valid object.'); | $errors[] = pht('Choose a valid object.'); | ||||
} else if (!$can_edit) { | } else if (!$can_edit) { | ||||
$errors[] = pht( | $errors[] = pht( | ||||
'You do not have permission to edit the selected object. '. | 'You do not have permission to edit the selected object. '. | ||||
'You can only install dashboards on objects you can edit.'); | 'You can only install dashboards on objects you can edit.'); | ||||
} | } | ||||
} else if ($request->getBool('pick')) { | } else if ($request->getBool('pick')) { | ||||
Show All 14 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 verified the above line
The input string is supposed to be a string, or null.
The function phutil_nonempty_string() will report alien values, and that is OK.