@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 an issue with serializing reviewers over the wire

Fixes T10981. Ref T10939. `arc` currently has some odd, hard-coded checks
(missing reviewers, all reviewers away) that depend on the field value being
in a certain format.

The recent changes swapped the field value from scalars (PHIDs) to
dictionaries and broke this workflow. It worked fine in testing because we
apply these checks very inconsistently (not on update or `--edit`).

To get around this for now, serialize into "PHID!" and then unserialize on
the other side. This is icky but keeps us from needing to require an `arc`
upgrade.

These checks are generally bad news and should move to the server side in the
long run (T4631).

(This probably prevents clean `arc diff`, so I'm just cowboy committing it.)

Auditors: chad

+37 -1
+37 -1
src/applications/differential/customfield/DifferentialReviewersField.php
··· 180 180 } 181 181 182 182 public function parseValueFromCommitMessage($value) { 183 - return $this->parseObjectList( 183 + $results = $this->parseObjectList( 184 184 $value, 185 185 array( 186 186 PhabricatorPeopleUserPHIDType::TYPECONST, ··· 189 189 ), 190 190 false, 191 191 array('!')); 192 + 193 + return $this->flattenReviewers($results); 192 194 } 193 195 194 196 public function getRequiredHandlePHIDsForCommitMessage() { ··· 196 198 } 197 199 198 200 public function readValueFromCommitMessage($value) { 201 + $value = $this->inflateReviewers($value); 202 + 199 203 $reviewers = array(); 200 204 foreach ($value as $spec) { 201 205 $phid = $spec['phid']; ··· 285 289 'You can mark a reviewer as blocking by adding an exclamation '. 286 290 'mark ("!") after their name.'), 287 291 ); 292 + } 293 + 294 + private function flattenReviewers(array $values) { 295 + // NOTE: For now, `arc` relies on this field returning only scalars, so we 296 + // need to reduce the results into scalars. See T10981. 297 + $result = array(); 298 + 299 + foreach ($values as $value) { 300 + $result[] = $value['phid'].implode('', array_keys($value['suffixes'])); 301 + } 302 + 303 + return $result; 304 + } 305 + 306 + private function inflateReviewers(array $values) { 307 + $result = array(); 308 + 309 + foreach ($values as $value) { 310 + if (substr($value, -1) == '!') { 311 + $value = substr($value, 0, -1); 312 + $suffixes = array('!' => '!'); 313 + } else { 314 + $suffixes = array(); 315 + } 316 + 317 + $result[] = array( 318 + 'phid' => $value, 319 + 'suffixes' => $suffixes, 320 + ); 321 + } 322 + 323 + return $result; 288 324 } 289 325 290 326 }