@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix error in `PhabricatorSetupIssueView`

Summary:
- Move `prettyPrintJSON()` and make it static.
- Use it from `PhabricatorSetupIssueView`
- Update other `config/` places that use it to call it from the new class.

This fixes a bug in `PhabricatorSetupIssueView` which showed up if the value
was an array and couldn't be rendered by `phutil_escape_html()`.

Test Plan:
- Rendered some config options.
- Went to /config/issue/config.unknown.phame.skins/ without error.

Reviewers: epriestley, btrahan, chad

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2255

Differential Revision: https://secure.phabricator.com/D4411

authored by

Ricky Elrod and committed by
epriestley
76c10f49 08687c0b

+27 -20
+1
src/__phutil_library_map__.php
··· 706 706 'PhabricatorConfigGroupController' => 'applications/config/controller/PhabricatorConfigGroupController.php', 707 707 'PhabricatorConfigIssueListController' => 'applications/config/controller/PhabricatorConfigIssueListController.php', 708 708 'PhabricatorConfigIssueViewController' => 'applications/config/controller/PhabricatorConfigIssueViewController.php', 709 + 'PhabricatorConfigJSON' => 'applications/config/json/PhabricatorConfigJSON.php', 709 710 'PhabricatorConfigListController' => 'applications/config/controller/PhabricatorConfigListController.php', 710 711 'PhabricatorConfigLocalSource' => 'infrastructure/env/PhabricatorConfigLocalSource.php', 711 712 'PhabricatorConfigManagementSetWorkflow' => 'infrastructure/env/management/PhabricatorConfigManagementSetWorkflow.php',
-16
src/applications/config/controller/PhabricatorConfigController.php
··· 21 21 return $this->buildSideNavView(null, true)->getMenu(); 22 22 } 23 23 24 - /** 25 - * Properly format a JSON value. 26 - * 27 - * @param wild Any value, but should be a raw value, not a string of JSON. 28 - * @return string 29 - */ 30 - public function prettyPrintJSON($value) { 31 - // Check not only that it's an array, but that it's an "unnatural" array 32 - // meaning that the keys aren't 0 -> size_of_array. 33 - if (is_array($value) && array_keys($value) != range(0, count($value) - 1)) { 34 - return id(new PhutilJSON())->encodeFormatted($value); 35 - } else { 36 - return json_encode($value); 37 - } 38 - } 39 - 40 24 }
+3 -2
src/applications/config/controller/PhabricatorConfigEditController.php
··· 330 330 case 'list<string>': 331 331 return implode("\n", nonempty($value, array())); 332 332 default: 333 - return $this->prettyPrintJSON($value); 333 + return PhabricatorConfigJSON::prettyPrintJSON($value); 334 334 } 335 335 } 336 336 ··· 462 462 if (!array_key_exists($option->getKey(), $value)) { 463 463 $value = '<em>'.pht('(empty)').'</em>'; 464 464 } else { 465 - $value = $this->prettyPrintJSON($value[$option->getKey()]); 465 + $value = PhabricatorConfigJSON::prettyPrintJSON( 466 + $value[$option->getKey()]); 466 467 } 467 468 468 469 $table[] = '<tr>';
+2 -1
src/applications/config/controller/PhabricatorConfigGroupController.php
··· 74 74 75 75 if (!$option->getHidden()) { 76 76 $current_value = PhabricatorEnv::getEnvConfig($option->getKey()); 77 - $current_value = $this->prettyPrintJSON($current_value); 77 + $current_value = PhabricatorConfigJSON::prettyPrintJSON( 78 + $current_value); 78 79 $current_value = phutil_render_tag( 79 80 'div', 80 81 array(
+19
src/applications/config/json/PhabricatorConfigJSON.php
··· 1 + <?php 2 + 3 + final class PhabricatorConfigJSON { 4 + /** 5 + * Properly format a JSON value. 6 + * 7 + * @param wild Any value, but should be a raw value, not a string of JSON. 8 + * @return string 9 + */ 10 + public static function prettyPrintJSON($value) { 11 + // Check not only that it's an array, but that it's an "unnatural" array 12 + // meaning that the keys aren't 0 -> size_of_array. 13 + if (is_array($value) && array_keys($value) != range(0, count($value) - 1)) { 14 + return id(new PhutilJSON())->encodeFormatted($value); 15 + } else { 16 + return json_encode($value); 17 + } 18 + } 19 + }
+2 -1
src/applications/config/view/PhabricatorSetupIssueView.php
··· 133 133 } else if ($value === true) { 134 134 $value = '<em>true</em>'; 135 135 } else { 136 - $value = phutil_escape_html($value); 136 + $value = phutil_escape_html( 137 + PhabricatorConfigJSON::prettyPrintJSON($value)); 137 138 } 138 139 139 140 $table[] = '<td>'.$value.'</td>';