mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-30 10:42:41 +01:00
Update callsites of phutil_json_decode
.
Summary: Depends on D9634. `phutil_json_decode` now throws an exception on invalid JSON. Test Plan: `arc unit` Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D9640
This commit is contained in:
parent
f7f8664456
commit
a4a8cfa6d6
5 changed files with 19 additions and 28 deletions
|
@ -13,20 +13,13 @@ abstract class PhabricatorConfigJSONOptionType
|
||||||
$display_value = $request->getStr('value');
|
$display_value = $request->getStr('value');
|
||||||
|
|
||||||
if (strlen($display_value)) {
|
if (strlen($display_value)) {
|
||||||
$storage_value = phutil_json_decode($display_value);
|
|
||||||
if ($storage_value === null) {
|
|
||||||
$e_value = pht('Invalid');
|
|
||||||
$errors[] = pht(
|
|
||||||
'Configuration value should be specified in JSON. The provided '.
|
|
||||||
'value is not valid JSON.');
|
|
||||||
} else {
|
|
||||||
try {
|
try {
|
||||||
|
$storage_value = phutil_json_decode($display_value);
|
||||||
$this->validateOption($option, $storage_value);
|
$this->validateOption($option, $storage_value);
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
$e_value = pht('Invalid');
|
$e_value = pht('Invalid');
|
||||||
$errors[] = $ex->getMessage();
|
$errors[] = $ex->getMessage();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$storage_value = null;
|
$storage_value = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,10 +38,7 @@ final class PhabricatorDashboardPanelTypeTabs
|
||||||
$config = $panel->getProperty('config');
|
$config = $panel->getProperty('config');
|
||||||
if (!is_array($config)) {
|
if (!is_array($config)) {
|
||||||
// NOTE: The older version of this panel stored raw JSON.
|
// NOTE: The older version of this panel stored raw JSON.
|
||||||
$config = phutil_json_decode($config, null);
|
$config = phutil_json_decode($config);
|
||||||
if ($config === null) {
|
|
||||||
throw new Exception(pht('The configuration is not valid JSON.'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$list = id(new PHUIListView())
|
$list = id(new PHUIListView())
|
||||||
|
|
|
@ -20,7 +20,11 @@ final class DifferentialAuditorsField
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setValueFromStorage($value) {
|
public function setValueFromStorage($value) {
|
||||||
|
try {
|
||||||
$this->setValue(phutil_json_decode($value));
|
$this->setValue(phutil_json_decode($value));
|
||||||
|
} catch (PhutilJSONParserException $ex) {
|
||||||
|
$this->setValue(array());
|
||||||
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,11 @@ final class DifferentialJIRAIssuesField
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setValueFromStorage($value) {
|
public function setValueFromStorage($value) {
|
||||||
|
try {
|
||||||
$this->setValue(phutil_json_decode($value));
|
$this->setValue(phutil_json_decode($value));
|
||||||
|
} catch (PhutilJSONParserException $ex) {
|
||||||
|
$this->setValue(array());
|
||||||
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,16 +23,9 @@ final class DifferentialCommitMessageParserTestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
list($message, $fields, $output, $errors) = $parts;
|
list($message, $fields, $output, $errors) = $parts;
|
||||||
$fields = phutil_json_decode($fields, null);
|
$fields = phutil_json_decode($fields);
|
||||||
$output = phutil_json_decode($output, null);
|
$output = phutil_json_decode($output);
|
||||||
$errors = phutil_json_decode($errors, null);
|
$errors = phutil_json_decode($errors);
|
||||||
|
|
||||||
if ($fields === null || $output === null || $errors === null) {
|
|
||||||
throw new Exception(
|
|
||||||
pht(
|
|
||||||
'Expected test file "%s" to contain valid JSON in its sections.',
|
|
||||||
$file));
|
|
||||||
}
|
|
||||||
|
|
||||||
$parser = id(new DifferentialCommitMessageParser())
|
$parser = id(new DifferentialCommitMessageParser())
|
||||||
->setLabelMap($fields)
|
->setLabelMap($fields)
|
||||||
|
|
Loading…
Reference in a new issue