1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 01:02:42 +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:
Joshua Spence 2014-06-21 00:39:37 +10:00
parent f7f8664456
commit a4a8cfa6d6
5 changed files with 19 additions and 28 deletions

View file

@ -13,19 +13,12 @@ abstract class PhabricatorConfigJSONOptionType
$display_value = $request->getStr('value');
if (strlen($display_value)) {
$storage_value = phutil_json_decode($display_value);
if ($storage_value === null) {
try {
$storage_value = phutil_json_decode($display_value);
$this->validateOption($option, $storage_value);
} catch (Exception $ex) {
$e_value = pht('Invalid');
$errors[] = pht(
'Configuration value should be specified in JSON. The provided '.
'value is not valid JSON.');
} else {
try {
$this->validateOption($option, $storage_value);
} catch (Exception $ex) {
$e_value = pht('Invalid');
$errors[] = $ex->getMessage();
}
$errors[] = $ex->getMessage();
}
} else {
$storage_value = null;

View file

@ -38,10 +38,7 @@ final class PhabricatorDashboardPanelTypeTabs
$config = $panel->getProperty('config');
if (!is_array($config)) {
// NOTE: The older version of this panel stored raw JSON.
$config = phutil_json_decode($config, null);
if ($config === null) {
throw new Exception(pht('The configuration is not valid JSON.'));
}
$config = phutil_json_decode($config);
}
$list = id(new PHUIListView())

View file

@ -20,7 +20,11 @@ final class DifferentialAuditorsField
}
public function setValueFromStorage($value) {
$this->setValue(phutil_json_decode($value));
try {
$this->setValue(phutil_json_decode($value));
} catch (PhutilJSONParserException $ex) {
$this->setValue(array());
}
return $this;
}

View file

@ -26,7 +26,11 @@ final class DifferentialJIRAIssuesField
}
public function setValueFromStorage($value) {
$this->setValue(phutil_json_decode($value));
try {
$this->setValue(phutil_json_decode($value));
} catch (PhutilJSONParserException $ex) {
$this->setValue(array());
}
return $this;
}

View file

@ -23,16 +23,9 @@ final class DifferentialCommitMessageParserTestCase
}
list($message, $fields, $output, $errors) = $parts;
$fields = phutil_json_decode($fields, null);
$output = phutil_json_decode($output, null);
$errors = phutil_json_decode($errors, null);
if ($fields === null || $output === null || $errors === null) {
throw new Exception(
pht(
'Expected test file "%s" to contain valid JSON in its sections.',
$file));
}
$fields = phutil_json_decode($fields);
$output = phutil_json_decode($output);
$errors = phutil_json_decode($errors);
$parser = id(new DifferentialCommitMessageParser())
->setLabelMap($fields)