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

Improve validation errors for changing task priorities

Summary:
Ref T12124. Currently, Conduit provides a fairly rough error message if you provide an invalid priority.

Instead, provide a more tailored message. Also, block `!!unknown!!` except from web edits.

Test Plan:
Before:

{F5007964}

After:

{F5007965}

Also, changed a priority to `999` in the database, edited it with the normal web UI form, it let me make the edit without being forced to adjust the priority.

Reviewers: amckinley, chad

Reviewed By: amckinley

Maniphest Tasks: T12124

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

+46
+46
src/applications/maniphest/xaction/ManiphestTaskPriorityTransaction.php
··· 129 129 } 130 130 } 131 131 132 + public function validateTransactions($object, array $xactions) { 133 + $errors = array(); 134 + 135 + $content_source = $this->getEditor()->getContentSource(); 136 + $is_web = ($content_source instanceof PhabricatorWebContentSource); 137 + 138 + foreach ($xactions as $xaction) { 139 + $value = $xaction->getNewValue(); 140 + 141 + // If this is a legitimate keyword like "low" or "high", this transaction 142 + // is fine and apply normally. 143 + $keyword = ManiphestTaskPriority::getTaskPriorityFromKeyword($value); 144 + if ($keyword !== null) { 145 + continue; 146 + } 147 + 148 + // If this is the magic "don't change things" value for editing tasks 149 + // with an obsolete priority constant in the database, let it through if 150 + // this is a web edit. 151 + if ($value === ManiphestTaskPriority::UNKNOWN_PRIORITY_KEYWORD) { 152 + if ($is_web) { 153 + continue; 154 + } 155 + } 156 + 157 + $keyword_list = array(); 158 + foreach (ManiphestTaskPriority::getTaskPriorityMap() as $pri => $name) { 159 + $keyword = ManiphestTaskPriority::getKeywordForTaskPriority($pri); 160 + if ($keyword === null) { 161 + continue; 162 + } 163 + $keyword_list[] = $keyword; 164 + } 165 + 166 + $errors[] = $this->newInvalidError( 167 + pht( 168 + 'Task priority "%s" is not a valid task priority. Use a priority '. 169 + 'keyword to choose a task priority: %s.', 170 + $value, 171 + implode(', ', $keyword_list)), 172 + $xaction); 173 + } 174 + 175 + return $errors; 176 + } 177 + 132 178 }