@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.

Validate configuration of `maniphest.priorities`

Summary: Fixes T6132. We currently allow invalid configuration here; validate it.

Test Plan: Tried to save invalid config (negative priorities, string priorities, etc).

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T6132

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

+46 -2
+2
src/__phutil_library_map__.php
··· 1277 1277 'ManiphestInfoConduitAPIMethod' => 'applications/maniphest/conduit/ManiphestInfoConduitAPIMethod.php', 1278 1278 'ManiphestNameIndex' => 'applications/maniphest/storage/ManiphestNameIndex.php', 1279 1279 'ManiphestNameIndexEventListener' => 'applications/maniphest/event/ManiphestNameIndexEventListener.php', 1280 + 'ManiphestPriorityConfigOptionType' => 'applications/maniphest/config/ManiphestPriorityConfigOptionType.php', 1280 1281 'ManiphestPriorityEmailCommand' => 'applications/maniphest/command/ManiphestPriorityEmailCommand.php', 1281 1282 'ManiphestQueryConduitAPIMethod' => 'applications/maniphest/conduit/ManiphestQueryConduitAPIMethod.php', 1282 1283 'ManiphestQueryStatusesConduitAPIMethod' => 'applications/maniphest/conduit/ManiphestQueryStatusesConduitAPIMethod.php', ··· 5258 5259 'ManiphestInfoConduitAPIMethod' => 'ManiphestConduitAPIMethod', 5259 5260 'ManiphestNameIndex' => 'ManiphestDAO', 5260 5261 'ManiphestNameIndexEventListener' => 'PhabricatorEventListener', 5262 + 'ManiphestPriorityConfigOptionType' => 'PhabricatorConfigJSONOptionType', 5261 5263 'ManiphestPriorityEmailCommand' => 'ManiphestEmailCommand', 5262 5264 'ManiphestQueryConduitAPIMethod' => 'ManiphestConduitAPIMethod', 5263 5265 'ManiphestQueryStatusesConduitAPIMethod' => 'ManiphestConduitAPIMethod',
+10
src/applications/maniphest/config/ManiphestPriorityConfigOptionType.php
··· 1 + <?php 2 + 3 + final class ManiphestPriorityConfigOptionType 4 + extends PhabricatorConfigJSONOptionType { 5 + 6 + public function validateOption(PhabricatorConfigOption $option, $value) { 7 + ManiphestTaskPriority::validateConfiguration($value); 8 + } 9 + 10 + }
+5 -2
src/applications/maniphest/config/PhabricatorManiphestConfigOptions.php
··· 20 20 } 21 21 22 22 public function getOptions() { 23 - 23 + $priority_type = 'custom:ManiphestPriorityConfigOptionType'; 24 24 $priority_defaults = array( 25 25 100 => array( 26 26 'name' => pht('Unbreak Now!'), ··· 267 267 $this->newOption('maniphest.fields', $custom_field_type, $default_fields) 268 268 ->setCustomData(id(new ManiphestTask())->getCustomFieldBaseClass()) 269 269 ->setDescription(pht('Select and reorder task fields.')), 270 - $this->newOption('maniphest.priorities', 'wild', $priority_defaults) 270 + $this->newOption( 271 + 'maniphest.priorities', 272 + $priority_type, 273 + $priority_defaults) 271 274 ->setSummary(pht('Configure Maniphest priority names.')) 272 275 ->setDescription( 273 276 pht(
+29
src/applications/maniphest/constants/ManiphestTaskPriority.php
··· 116 116 return $config; 117 117 } 118 118 119 + public static function validateConfiguration(array $config) { 120 + foreach ($config as $key => $value) { 121 + if (!ctype_digit((string)$key)) { 122 + throw new Exception( 123 + pht( 124 + 'Key "%s" is not a valid priority constant. Priority constants '. 125 + 'must be nonnegative integers.', 126 + $key)); 127 + } 128 + 129 + if (!is_array($value)) { 130 + throw new Exception( 131 + pht( 132 + 'Value for key "%s" should be a dictionary.', 133 + $key)); 134 + } 135 + 136 + PhutilTypeSpec::checkMap( 137 + $value, 138 + array( 139 + 'name' => 'string', 140 + 'short' => 'optional string', 141 + 'color' => 'optional string', 142 + 'keywords' => 'optional list<string>', 143 + 'disabled' => 'optional bool', 144 + )); 145 + } 146 + } 147 + 119 148 }