diff --git a/scripts/celerity/generate_sprites.php b/scripts/celerity/generate_sprites.php index b86ea53e26..31ad4684c2 100755 --- a/scripts/celerity/generate_sprites.php +++ b/scripts/celerity/generate_sprites.php @@ -53,7 +53,7 @@ foreach ($sheets as $name => $sheet) { if (!$args->getArg('force')) { if (Filesystem::pathExists($manifest_path)) { $data = Filesystem::readFile($manifest_path); - $data = json_decode($data, true); + $data = phutil_json_decode($data); if (!$sheet->needsRegeneration($data)) { continue; } diff --git a/src/applications/conduit/controller/PhabricatorConduitAPIController.php b/src/applications/conduit/controller/PhabricatorConduitAPIController.php index 135091534c..e8e69f18e3 100644 --- a/src/applications/conduit/controller/PhabricatorConduitAPIController.php +++ b/src/applications/conduit/controller/PhabricatorConduitAPIController.php @@ -647,12 +647,15 @@ final class PhabricatorConduitAPIController // entire param dictionary JSON encoded. $params_json = $request->getStr('params'); if (strlen($params_json)) { - $params = json_decode($params_json, true); - if (!is_array($params)) { - throw new Exception( - "Invalid parameter information was passed to method ". - "'{$method}', could not decode JSON serialization. Data: ". - $params_json); + $params = null; + try { + $params = phutil_json_decode($params_json); + } catch (PhutilJSONParserException $ex) { + throw new PhutilProxyException( + pht( + "Invalid parameter information was passed to method '%s'", + $method), + $ex); } $metadata = idx($params, '__conduit__', array()); diff --git a/src/applications/conduit/ssh/ConduitSSHWorkflow.php b/src/applications/conduit/ssh/ConduitSSHWorkflow.php index bbc809bca6..aed7004d7e 100644 --- a/src/applications/conduit/ssh/ConduitSSHWorkflow.php +++ b/src/applications/conduit/ssh/ConduitSSHWorkflow.php @@ -26,13 +26,17 @@ final class ConduitSSHWorkflow extends PhabricatorSSHWorkflow { $method = head($methodv); $json = $this->readAllInput(); - $raw_params = json_decode($json, true); - if (!is_array($raw_params)) { - throw new Exception('Invalid JSON input.'); + $raw_params = null; + try { + $raw_params = phutil_json_decode($json); + } catch (PhutilJSONParserException $ex) { + throw new PhutilProxyException( + pht('Invalid JSON input.'), + $ex); } $params = idx($raw_params, 'params', '[]'); - $params = json_decode($params, true); + $params = phutil_json_decode($params); $metadata = idx($params, '__conduit__', array()); unset($params['__conduit__']); diff --git a/src/applications/console/controller/DarkConsoleDataController.php b/src/applications/console/controller/DarkConsoleDataController.php index fd5350679d..6582189f48 100644 --- a/src/applications/console/controller/DarkConsoleDataController.php +++ b/src/applications/console/controller/DarkConsoleDataController.php @@ -33,9 +33,9 @@ final class DarkConsoleDataController extends PhabricatorController { return new Aphront400Response(); } - $result = json_decode($result, true); - - if (!is_array($result)) { + try { + $result = phutil_json_decode($result); + } catch (PhutilJSONParserException $ex) { return new Aphront400Response(); } diff --git a/src/applications/differential/__tests__/DifferentialParseRenderTestCase.php b/src/applications/differential/__tests__/DifferentialParseRenderTestCase.php index 430aa77c89..9805cc7259 100644 --- a/src/applications/differential/__tests__/DifferentialParseRenderTestCase.php +++ b/src/applications/differential/__tests__/DifferentialParseRenderTestCase.php @@ -17,9 +17,12 @@ final class DifferentialParseRenderTestCase extends PhabricatorTestCase { $opt_file = $dir.$file.'.options'; if (Filesystem::pathExists($opt_file)) { $options = Filesystem::readFile($opt_file); - $options = json_decode($options, true); - if (!is_array($options)) { - throw new Exception("Invalid options file: {$opt_file}."); + try { + $options = phutil_json_decode($options); + } catch (PhutilJSONParserException $ex) { + throw new PhutilProxyException( + pht('Invalid options file: %s.', $opt_file), + $ex); } } else { $options = array(); diff --git a/src/applications/differential/conduit/DifferentialSetDiffPropertyConduitAPIMethod.php b/src/applications/differential/conduit/DifferentialSetDiffPropertyConduitAPIMethod.php index d79be1363d..d6e326fe5d 100644 --- a/src/applications/differential/conduit/DifferentialSetDiffPropertyConduitAPIMethod.php +++ b/src/applications/differential/conduit/DifferentialSetDiffPropertyConduitAPIMethod.php @@ -86,7 +86,7 @@ final class DifferentialSetDiffPropertyConduitAPIMethod protected function execute(ConduitAPIRequest $request) { $diff_id = $request->getValue('diff_id'); $name = $request->getValue('name'); - $data = json_decode($request->getValue('data'), true); + $data = phutil_json_decode($request->getValue('data')); self::updateDiffProperty($diff_id, $name, $data); diff --git a/src/applications/diffusion/DiffusionLintSaveRunner.php b/src/applications/diffusion/DiffusionLintSaveRunner.php index d1f0005c21..26a98a0232 100644 --- a/src/applications/diffusion/DiffusionLintSaveRunner.php +++ b/src/applications/diffusion/DiffusionLintSaveRunner.php @@ -154,9 +154,11 @@ final class DiffusionLintSaveRunner { $files); foreach (new LinesOfALargeExecFuture($future) as $json) { - $paths = json_decode($json, true); - if (!is_array($paths)) { - fprintf(STDERR, "Invalid JSON: {$json}\n"); + $paths = null; + try { + $paths = phutil_json_decode($json); + } catch (PhutilJSONParserException $ex) { + fprintf(STDERR, pht("Invalid JSON: %s\n", $json)); continue; } diff --git a/src/applications/diffusion/controller/DiffusionLastModifiedController.php b/src/applications/diffusion/controller/DiffusionLastModifiedController.php index 58b60995d4..3487733c8b 100644 --- a/src/applications/diffusion/controller/DiffusionLastModifiedController.php +++ b/src/applications/diffusion/controller/DiffusionLastModifiedController.php @@ -11,8 +11,9 @@ final class DiffusionLastModifiedController extends DiffusionController { $viewer = $request->getUser(); $paths = $request->getStr('paths'); - $paths = json_decode($paths, true); - if (!is_array($paths)) { + try { + $paths = phutil_json_decode($paths); + } catch (PhutilJSONParserException $ex) { return new Aphront400Response(); } diff --git a/src/applications/diffusion/ssh/__tests__/DiffusionMercurialWireSSHTestCase.php b/src/applications/diffusion/ssh/__tests__/DiffusionMercurialWireSSHTestCase.php index 48e7ca7aa5..694f4cd11d 100644 --- a/src/applications/diffusion/ssh/__tests__/DiffusionMercurialWireSSHTestCase.php +++ b/src/applications/diffusion/ssh/__tests__/DiffusionMercurialWireSSHTestCase.php @@ -9,7 +9,7 @@ final class DiffusionMercurialWireSSHTestCase extends PhabricatorTestCase { $raw = Filesystem::readFile($data.$file); $raw = explode("\n~~~~~~~~~~\n", $raw, 2); $this->assertEqual(2, count($raw)); - $expect = json_decode($raw[1], true); + $expect = phutil_json_decode($raw[1]); $this->assertTrue(is_array($expect), $file); $this->assertParserResult($expect, $raw[0], $file); diff --git a/src/applications/doorkeeper/controller/DoorkeeperTagsController.php b/src/applications/doorkeeper/controller/DoorkeeperTagsController.php index fbb627c527..12ff8e72c5 100644 --- a/src/applications/doorkeeper/controller/DoorkeeperTagsController.php +++ b/src/applications/doorkeeper/controller/DoorkeeperTagsController.php @@ -7,8 +7,9 @@ final class DoorkeeperTagsController extends PhabricatorController { $viewer = $request->getUser(); $tags = $request->getStr('tags'); - $tags = json_decode($tags, true); - if (!is_array($tags)) { + try { + $tags = phutil_json_decode($tags); + } catch (PhutilJSONParserException $ex) { $tags = array(); } diff --git a/src/applications/help/controller/PhabricatorHelpKeyboardShortcutController.php b/src/applications/help/controller/PhabricatorHelpKeyboardShortcutController.php index 55321a9155..f91182859a 100644 --- a/src/applications/help/controller/PhabricatorHelpKeyboardShortcutController.php +++ b/src/applications/help/controller/PhabricatorHelpKeyboardShortcutController.php @@ -12,8 +12,9 @@ final class PhabricatorHelpKeyboardShortcutController $user = $request->getUser(); $keys = $request->getStr('keys'); - $keys = json_decode($keys, true); - if (!is_array($keys)) { + try { + $keys = phutil_json_decode($keys); + } catch (PhutilJSONParserException $ex) { return new Aphront400Response(); } diff --git a/src/applications/herald/adapter/HeraldAdapter.php b/src/applications/herald/adapter/HeraldAdapter.php index 120caccb81..6a51ade55f 100644 --- a/src/applications/herald/adapter/HeraldAdapter.php +++ b/src/applications/herald/adapter/HeraldAdapter.php @@ -633,14 +633,16 @@ abstract class HeraldAdapter { // dictionary. The first regexp must match the dictionary key, and the // second regexp must match the dictionary value. If any key/value pair // in the dictionary matches both regexps, the condition is satisfied. - $regexp_pair = json_decode($condition_value, true); - if (!is_array($regexp_pair)) { + $regexp_pair = null; + try { + $regexp_pair = phutil_json_decode($condition_value); + } catch (PhutilJSONParserException $ex) { throw new HeraldInvalidConditionException( - 'Regular expression pair is not valid JSON!'); + pht('Regular expression pair is not valid JSON!')); } if (count($regexp_pair) != 2) { throw new HeraldInvalidConditionException( - 'Regular expression pair is not a pair!'); + pht('Regular expression pair is not a pair!')); } $key_regexp = array_shift($regexp_pair); @@ -705,8 +707,10 @@ abstract class HeraldAdapter { } break; case self::CONDITION_REGEXP_PAIR: - $json = json_decode($condition_value, true); - if (!is_array($json)) { + $json = null; + try { + $json = phutil_json_decode($condition_value); + } catch (PhutilJSONParserException $ex) { throw new HeraldInvalidConditionException( pht( 'The regular expression pair "%s" is not valid JSON. Enter a '. diff --git a/src/applications/herald/controller/HeraldRuleController.php b/src/applications/herald/controller/HeraldRuleController.php index 6780693031..c290407097 100644 --- a/src/applications/herald/controller/HeraldRuleController.php +++ b/src/applications/herald/controller/HeraldRuleController.php @@ -258,7 +258,15 @@ final class HeraldRuleController extends HeraldController { $errors[] = pht('Rule must have a name.'); } - $data = json_decode($request->getStr('rule'), true); + $data = null; + try { + $data = phutil_json_decode($request->getStr('rule')); + } catch (PhutilJSONParserException $ex) { + throw new PhutilProxyException( + pht('Failed to decode rule data.'), + $ex); + } + if (!is_array($data) || !$data['conditions'] || !$data['actions']) { diff --git a/src/applications/maniphest/controller/ManiphestBatchEditController.php b/src/applications/maniphest/controller/ManiphestBatchEditController.php index 75900acd53..58c8ffce1c 100644 --- a/src/applications/maniphest/controller/ManiphestBatchEditController.php +++ b/src/applications/maniphest/controller/ManiphestBatchEditController.php @@ -47,7 +47,7 @@ final class ManiphestBatchEditController extends ManiphestController { $actions = $request->getStr('actions'); if ($actions) { - $actions = json_decode($actions, true); + $actions = phutil_json_decode($actions); } if ($request->isFormPost() && is_array($actions)) { diff --git a/src/applications/maniphest/controller/ManiphestTransactionPreviewController.php b/src/applications/maniphest/controller/ManiphestTransactionPreviewController.php index 36fe8d7493..0d7988cd64 100644 --- a/src/applications/maniphest/controller/ManiphestTransactionPreviewController.php +++ b/src/applications/maniphest/controller/ManiphestTransactionPreviewController.php @@ -74,7 +74,7 @@ final class ManiphestTransactionPreviewController extends ManiphestController { break; case PhabricatorTransactions::TYPE_EDGE: if ($value) { - $value = json_decode($value); + $value = phutil_json_decode($value); } if (!$value) { $value = array(); diff --git a/src/applications/metamta/adapter/PhabricatorMailImplementationMailgunAdapter.php b/src/applications/metamta/adapter/PhabricatorMailImplementationMailgunAdapter.php index 3a55f10e1d..c812f1ed4a 100644 --- a/src/applications/metamta/adapter/PhabricatorMailImplementationMailgunAdapter.php +++ b/src/applications/metamta/adapter/PhabricatorMailImplementationMailgunAdapter.php @@ -120,9 +120,13 @@ final class PhabricatorMailImplementationMailgunAdapter list($body) = $future->resolvex(); - $response = json_decode($body, true); - if (!is_array($response)) { - throw new Exception("Failed to JSON decode response: {$body}"); + $response = null; + try { + $response = phutil_json_decode($body); + } catch (PhutilJSONParserException $ex) { + throw new PhutilProxyException( + pht('Failed to JSON decode response.'), + $ex); } if (!idx($response, 'id')) { diff --git a/src/applications/metamta/adapter/PhabricatorMailImplementationSendGridAdapter.php b/src/applications/metamta/adapter/PhabricatorMailImplementationSendGridAdapter.php index dcb037bf09..566d33fd14 100644 --- a/src/applications/metamta/adapter/PhabricatorMailImplementationSendGridAdapter.php +++ b/src/applications/metamta/adapter/PhabricatorMailImplementationSendGridAdapter.php @@ -78,8 +78,10 @@ final class PhabricatorMailImplementationSendGridAdapter if (!$user || !$key) { throw new Exception( - "Configure 'sendgrid.api-user' and 'sendgrid.api-key' to use ". - "SendGrid for mail delivery."); + pht( + "Configure '%s' and '%s' to use SendGrid for mail delivery.", + 'sendgrid.api-user', + 'sendgrid.api-key')); } $params = array(); @@ -142,14 +144,18 @@ final class PhabricatorMailImplementationSendGridAdapter list($body) = $future->resolvex(); - $response = json_decode($body, true); - if (!is_array($response)) { - throw new Exception("Failed to JSON decode response: {$body}"); + $response = null; + try { + $response = phutil_json_decode($body); + } catch (PhutilJSONParserException $ex) { + throw new PhutilProxyException( + pht('Failed to JSON decode response.'), + $ex); } if ($response['message'] !== 'success') { $errors = implode(';', $response['errors']); - throw new Exception("Request failed with errors: {$errors}."); + throw new Exception(pht('Request failed with errors: %s.', $errors)); } return true; diff --git a/src/applications/metamta/contentsource/PhabricatorContentSource.php b/src/applications/metamta/contentsource/PhabricatorContentSource.php index a1cbd061f2..ce2341186c 100644 --- a/src/applications/metamta/contentsource/PhabricatorContentSource.php +++ b/src/applications/metamta/contentsource/PhabricatorContentSource.php @@ -32,7 +32,7 @@ final class PhabricatorContentSource { } public static function newFromSerialized($serialized) { - $dict = json_decode($serialized, true); + $dict = phutil_json_decode($serialized); if (!is_array($dict)) { $dict = array(); } diff --git a/src/applications/phame/skins/PhameSkinSpecification.php b/src/applications/phame/skins/PhameSkinSpecification.php index 0303bdf12d..506f89a811 100644 --- a/src/applications/phame/skins/PhameSkinSpecification.php +++ b/src/applications/phame/skins/PhameSkinSpecification.php @@ -93,15 +93,18 @@ final class PhameSkinSpecification { } private static function loadSkinSpecification($path) { - $config_path = $path.DIRECTORY_SEPARATOR.'skin.json'; $config = array(); if (Filesystem::pathExists($config_path)) { $config = Filesystem::readFile($config_path); - $config = json_decode($config, true); - if (!is_array($config)) { - throw new Exception( - "Skin configuration file '{$config_path}' is not a valid JSON file."); + try { + $config = phutil_json_decode($config); + } catch (PhutilJSONParserException $ex) { + throw new PhutilProxyException( + pht( + "Skin configuration file '%s' is not a valid JSON file.", + $config_path), + $ex); } $type = idx($config, 'type', self::TYPE_BASIC); } else { diff --git a/src/applications/phortune/controller/PhortunePaymentMethodCreateController.php b/src/applications/phortune/controller/PhortunePaymentMethodCreateController.php index 50210fa76c..844dd2ed5e 100644 --- a/src/applications/phortune/controller/PhortunePaymentMethodCreateController.php +++ b/src/applications/phortune/controller/PhortunePaymentMethodCreateController.php @@ -94,20 +94,23 @@ final class PhortunePaymentMethodCreateController if (!$errors) { $client_token_raw = $request->getStr('token'); - $client_token = json_decode($client_token_raw, true); - if (!is_array($client_token)) { + $client_token = null; + try { + $client_token = phutil_json_decode($client_token_raw); + } catch (PhutilJSONParserException $ex) { $errors[] = pht( 'There was an error decoding token information submitted by the '. 'client. Expected a JSON-encoded token dictionary, received: %s.', nonempty($client_token_raw, pht('nothing'))); - } else { - if (!$provider->validateCreatePaymentMethodToken($client_token)) { - $errors[] = pht( - 'There was an error with the payment token submitted by the '. - 'client. Expected a valid dictionary, received: %s.', - $client_token_raw); - } } + + if (!$provider->validateCreatePaymentMethodToken($client_token)) { + $errors[] = pht( + 'There was an error with the payment token submitted by the '. + 'client. Expected a valid dictionary, received: %s.', + $client_token_raw); + } + if (!$errors) { $errors = $provider->createPaymentMethodFromRequest( $request, @@ -215,8 +218,10 @@ final class PhortunePaymentMethodCreateController $errors = array(); - $client_errors = json_decode($client_errors_raw, true); - if (!is_array($client_errors)) { + $client_errors = null; + try { + $client_errors = phutil_json_decode($client_errors_raw); + } catch (PhutilJSONParserException $ex) { $errors[] = pht( 'There was an error decoding error information submitted by the '. 'client. Expected a JSON-encoded list of error codes, received: %s.', diff --git a/src/applications/policy/controller/PhabricatorPolicyEditController.php b/src/applications/policy/controller/PhabricatorPolicyEditController.php index 3347712ac8..d8cf20d38a 100644 --- a/src/applications/policy/controller/PhabricatorPolicyEditController.php +++ b/src/applications/policy/controller/PhabricatorPolicyEditController.php @@ -52,9 +52,12 @@ final class PhabricatorPolicyEditController $errors = array(); if ($request->isFormPost()) { $data = $request->getStr('rules'); - $data = @json_decode($data, true); - if (!is_array($data)) { - throw new Exception('Failed to JSON decode rule data!'); + try { + $data = phutil_json_decode($data); + } catch (PhutilJSONParserException $ex) { + throw new PhutilProxyException( + pht('Failed to JSON decode rule data!'), + $ex); } $rule_data = array(); diff --git a/src/applications/releeph/differential/DifferentialReleephRequestFieldSpecification.php b/src/applications/releeph/differential/DifferentialReleephRequestFieldSpecification.php index 02ffa826b2..1c2a10eace 100644 --- a/src/applications/releeph/differential/DifferentialReleephRequestFieldSpecification.php +++ b/src/applications/releeph/differential/DifferentialReleephRequestFieldSpecification.php @@ -39,7 +39,7 @@ final class DifferentialReleephRequestFieldSpecification { public function setValueFromStorage($json) { if ($json) { - $dict = json_decode($json, true); + $dict = phutil_json_decode($json); $this->releephAction = idx($dict, 'releephAction'); $this->releephPHIDs = idx($dict, 'releephPHIDs'); } diff --git a/src/applications/search/engine/PhabricatorElasticSearchEngine.php b/src/applications/search/engine/PhabricatorElasticSearchEngine.php index 15f5ee7a61..4b30fb4c66 100644 --- a/src/applications/search/engine/PhabricatorElasticSearchEngine.php +++ b/src/applications/search/engine/PhabricatorElasticSearchEngine.php @@ -397,12 +397,13 @@ final class PhabricatorElasticSearchEngine extends PhabricatorSearchEngine { return null; } - $body = json_decode($body, true); - if (!is_array($body)) { - throw new Exception('elasticsearch server returned invalid JSON!'); + try { + return phutil_json_decode($body); + } catch (PhutilJSONParserException $ex) { + throw new PhutilProxyException( + pht('ElasticSearch server returned invalid JSON!'), + $ex); } - - return $body; } } diff --git a/src/applications/xhprof/controller/PhabricatorXHProfProfileController.php b/src/applications/xhprof/controller/PhabricatorXHProfProfileController.php index 15f6c47c66..11e9e47ffc 100644 --- a/src/applications/xhprof/controller/PhabricatorXHProfProfileController.php +++ b/src/applications/xhprof/controller/PhabricatorXHProfProfileController.php @@ -21,9 +21,12 @@ final class PhabricatorXHProfProfileController } $data = $file->loadFileData(); - $data = @json_decode($data, true); - if (!$data) { - throw new Exception('Failed to unserialize XHProf profile!'); + try { + $data = phutil_json_decode($data); + } catch (PhutilJSONParserException $ex) { + throw new PhutilProxyException( + pht('Failed to unserialize XHProf profile!'), + $ex); } $symbol = $request->getStr('symbol'); diff --git a/src/infrastructure/customfield/config/PhabricatorCustomFieldConfigOptionType.php b/src/infrastructure/customfield/config/PhabricatorCustomFieldConfigOptionType.php index b26441f233..6ff9eae1d0 100644 --- a/src/infrastructure/customfield/config/PhabricatorCustomFieldConfigOptionType.php +++ b/src/infrastructure/customfield/config/PhabricatorCustomFieldConfigOptionType.php @@ -11,7 +11,7 @@ final class PhabricatorCustomFieldConfigOptionType $errors = array(); $storage_value = $request->getStr('value'); - $in_value = json_decode($storage_value, true); + $in_value = phutil_json_decode($storage_value); if (!is_array($in_value)) { $in_value = array(); } diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php index 4eb06e66f2..68b5f44a77 100644 --- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php +++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php @@ -124,7 +124,7 @@ abstract class PhabricatorStandardCustomFieldPHIDs $old = array(); } - $new = json_decode($xaction->getNewValue()); + $new = phutil_json_decode($xaction->getNewValue()); if (!is_array($new)) { $new = array(); } diff --git a/src/infrastructure/daemon/bot/PhabricatorBot.php b/src/infrastructure/daemon/bot/PhabricatorBot.php index 6a453e1b0f..12ab9e663a 100644 --- a/src/infrastructure/daemon/bot/PhabricatorBot.php +++ b/src/infrastructure/daemon/bot/PhabricatorBot.php @@ -23,9 +23,12 @@ final class PhabricatorBot extends PhabricatorDaemon { } $json_raw = Filesystem::readFile($argv[0]); - $config = json_decode($json_raw, true); - if (!is_array($config)) { - throw new Exception("File '{$argv[0]}' is not valid JSON!"); + try { + $config = phutil_json_decode($json_raw); + } catch (PhutilJSONParserException $ex) { + throw new PhutilProxyException( + pht("File '%s' is not valid JSON!", $argv[0]), + $ex); } $nick = idx($config, 'nick', 'phabot'); diff --git a/src/infrastructure/daemon/bot/adapter/PhabricatorBotBaseStreamingProtocolAdapter.php b/src/infrastructure/daemon/bot/adapter/PhabricatorBotBaseStreamingProtocolAdapter.php index 83b0dd40bb..fc2cce4796 100644 --- a/src/infrastructure/daemon/bot/adapter/PhabricatorBotBaseStreamingProtocolAdapter.php +++ b/src/infrastructure/daemon/bot/adapter/PhabricatorBotBaseStreamingProtocolAdapter.php @@ -124,7 +124,7 @@ abstract class PhabricatorBotBaseStreamingProtocolAdapter $message = substr($buffer, 0, $until + 1); $buffer = substr($buffer, $until + 2); - $m_obj = json_decode($message, true); + $m_obj = phutil_json_decode($message); if ($message = $this->processMessage($m_obj)) { return $message; } @@ -149,7 +149,7 @@ abstract class PhabricatorBotBaseStreamingProtocolAdapter $output = trim($output); if (strlen($output)) { - return json_decode($output, true); + return phutil_json_decode($output); } return true; @@ -165,6 +165,6 @@ abstract class PhabricatorBotBaseStreamingProtocolAdapter abstract protected function buildStreamingUrl($channel); - abstract protected function processMessage($raw_object); + abstract protected function processMessage(array $raw_object); } diff --git a/src/infrastructure/daemon/bot/adapter/PhabricatorBotFlowdockProtocolAdapter.php b/src/infrastructure/daemon/bot/adapter/PhabricatorBotFlowdockProtocolAdapter.php index 3a5102568c..050377dc77 100644 --- a/src/infrastructure/daemon/bot/adapter/PhabricatorBotFlowdockProtocolAdapter.php +++ b/src/infrastructure/daemon/bot/adapter/PhabricatorBotFlowdockProtocolAdapter.php @@ -26,7 +26,7 @@ final class PhabricatorBotFlowdockProtocolAdapter return $url; } - protected function processMessage($m_obj) { + protected function processMessage(array $m_obj) { $command = null; switch ($m_obj['event']) { case 'message': diff --git a/src/infrastructure/daemon/bot/adapter/PhabricatorCampfireProtocolAdapter.php b/src/infrastructure/daemon/bot/adapter/PhabricatorCampfireProtocolAdapter.php index 008ed9d7d6..3f07a7e7a0 100644 --- a/src/infrastructure/daemon/bot/adapter/PhabricatorCampfireProtocolAdapter.php +++ b/src/infrastructure/daemon/bot/adapter/PhabricatorCampfireProtocolAdapter.php @@ -16,7 +16,7 @@ final class PhabricatorCampfireProtocolAdapter return $url; } - protected function processMessage($m_obj) { + protected function processMessage(array $m_obj) { $command = null; switch ($m_obj['type']) { case 'TextMessage': diff --git a/src/infrastructure/daemon/workers/query/PhabricatorWorkerLeaseQuery.php b/src/infrastructure/daemon/workers/query/PhabricatorWorkerLeaseQuery.php index 07c3460494..36eca14d97 100644 --- a/src/infrastructure/daemon/workers/query/PhabricatorWorkerLeaseQuery.php +++ b/src/infrastructure/daemon/workers/query/PhabricatorWorkerLeaseQuery.php @@ -191,7 +191,7 @@ final class PhabricatorWorkerLeaseQuery extends PhabricatorQuery { foreach ($data as $row) { $tasks[$row['id']]->setServerTime($row['_serverTime']); if ($row['_taskData']) { - $task_data = json_decode($row['_taskData'], true); + $task_data = phutil_json_decode($row['_taskData']); } else { $task_data = null; } diff --git a/src/infrastructure/edges/query/PhabricatorEdgeQuery.php b/src/infrastructure/edges/query/PhabricatorEdgeQuery.php index 3ea7eb998e..1323d42e3e 100644 --- a/src/infrastructure/edges/query/PhabricatorEdgeQuery.php +++ b/src/infrastructure/edges/query/PhabricatorEdgeQuery.php @@ -201,7 +201,7 @@ final class PhabricatorEdgeQuery extends PhabricatorQuery { $data_ids); foreach ($data_rows as $row) { $data_map[$row['id']] = idx( - json_decode($row['data'], true), + phutil_json_decode($row['data']), 'data'); } } diff --git a/src/infrastructure/storage/lisk/LiskDAO.php b/src/infrastructure/storage/lisk/LiskDAO.php index d21001c0a3..6faa3bb4f8 100644 --- a/src/infrastructure/storage/lisk/LiskDAO.php +++ b/src/infrastructure/storage/lisk/LiskDAO.php @@ -1637,7 +1637,7 @@ abstract class LiskDAO { break; case self::SERIALIZATION_JSON: if ($deserialize) { - $data[$col] = json_decode($data[$col], true); + $data[$col] = phutil_json_decode($data[$col]); } else { $data[$col] = json_encode($data[$col]); } diff --git a/src/view/phui/PHUIIconView.php b/src/view/phui/PHUIIconView.php index 5651322952..0cb7be8db5 100644 --- a/src/view/phui/PHUIIconView.php +++ b/src/view/phui/PHUIIconView.php @@ -106,7 +106,7 @@ final class PHUIIconView extends AphrontTagView { $root = dirname(phutil_get_library_root('phabricator')); $path = $root.'/resources/sprite/manifest/'.$sheet.'.json'; $data = Filesystem::readFile($path); - return idx(json_decode($data, true), 'sprites'); + return idx(phutil_json_decode($data), 'sprites'); } public static function getFontIcons() {