Page MenuHomePhabricator

D9640.diff
No OneTemporary

D9640.diff

diff --git a/src/applications/config/custom/PhabricatorConfigJSONOptionType.php b/src/applications/config/custom/PhabricatorConfigJSONOptionType.php
--- a/src/applications/config/custom/PhabricatorConfigJSONOptionType.php
+++ b/src/applications/config/custom/PhabricatorConfigJSONOptionType.php
@@ -13,19 +13,12 @@
$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;
diff --git a/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeTabs.php b/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeTabs.php
--- a/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeTabs.php
+++ b/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeTabs.php
@@ -38,10 +38,7 @@
$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())
diff --git a/src/applications/differential/customfield/DifferentialAuditorsField.php b/src/applications/differential/customfield/DifferentialAuditorsField.php
--- a/src/applications/differential/customfield/DifferentialAuditorsField.php
+++ b/src/applications/differential/customfield/DifferentialAuditorsField.php
@@ -20,7 +20,11 @@
}
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;
}
diff --git a/src/applications/differential/customfield/DifferentialJIRAIssuesField.php b/src/applications/differential/customfield/DifferentialJIRAIssuesField.php
--- a/src/applications/differential/customfield/DifferentialJIRAIssuesField.php
+++ b/src/applications/differential/customfield/DifferentialJIRAIssuesField.php
@@ -26,7 +26,11 @@
}
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;
}
diff --git a/src/applications/differential/parser/__tests__/DifferentialCommitMessageParserTestCase.php b/src/applications/differential/parser/__tests__/DifferentialCommitMessageParserTestCase.php
--- a/src/applications/differential/parser/__tests__/DifferentialCommitMessageParserTestCase.php
+++ b/src/applications/differential/parser/__tests__/DifferentialCommitMessageParserTestCase.php
@@ -23,16 +23,9 @@
}
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)

File Metadata

Mime Type
text/plain
Expires
Fri, Dec 20, 3:54 AM (20 h, 43 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6909443
Default Alt Text
D9640.diff (4 KB)

Event Timeline