@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 where newly created tasks could appear at the bottom of columns

Summary:
Ref T10349. At HEAD, if you create a task //on a board//, it floats to the top correctly.

If you create a task elsewhere and tag it with the board, you were subject to the whims of the layout engine and it would generally end up on the bottom.

Instead, make the rules consistent so that "virtual" positions (of tasks which haven't been committed to a particular position yet) still float to the top.

Test Plan:
- Created tasks from a board.
- Created tasks from Maniphest, then looked at them on a board.
- Moved tasks around.
- In all cases, newly created tasks floated to the top.
- Sorted by natural and priority.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10349

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

+38 -12
+8 -2
src/applications/maniphest/editor/ManiphestTransactionEditor.php
··· 289 289 array($select_phids)) 290 290 ->execute(); 291 291 292 - $object_phids = mpull($board_tasks, 'getPHID'); 293 - $object_phids[] = $object_phid; 292 + $board_tasks = mpull($board_tasks, null, 'getPHID'); 293 + $board_tasks[$object_phid] = $object; 294 + 295 + // Make sure tasks are sorted by ID, so we lay out new positions in 296 + // a consistent way. 297 + $board_tasks = msort($board_tasks, 'getID'); 298 + 299 + $object_phids = array_keys($board_tasks); 294 300 295 301 $engine = id(new PhabricatorBoardLayoutEngine()) 296 302 ->setViewer($omnipotent_viewer)
+5 -1
src/applications/project/controller/PhabricatorProjectBoardViewController.php
··· 124 124 125 125 $board_phid = $project->getPHID(); 126 126 127 + // Regardless of display order, pass tasks to the layout engine in ID order 128 + // so layout is consistent. 129 + $board_tasks = msort($tasks, 'getID'); 130 + 127 131 $layout_engine = id(new PhabricatorBoardLayoutEngine()) 128 132 ->setViewer($viewer) 129 133 ->setBoardPHIDs(array($board_phid)) 130 - ->setObjectPHIDs(array_keys($tasks)) 134 + ->setObjectPHIDs(array_keys($board_tasks)) 131 135 ->setFetchAllBoards(true) 132 136 ->executeLayout(); 133 137
+5 -2
src/applications/project/engine/PhabricatorBoardLayoutEngine.php
··· 506 506 } 507 507 } 508 508 509 + $view_sequence = 1; 509 510 foreach ($object_phids as $object_phid) { 510 511 $positions = idx($position_groups, $object_phid, array()); 511 512 ··· 554 555 ->setBoardPHID($board_phid) 555 556 ->setColumnPHID($proxy_hit) 556 557 ->setObjectPHID($object_phid) 557 - ->setSequence(0); 558 + ->setSequence(0) 559 + ->setViewSequence($view_sequence++); 558 560 559 561 $this->addQueue[] = $new_position; 560 562 ··· 578 580 ->setBoardPHID($board_phid) 579 581 ->setColumnPHID($default_phid) 580 582 ->setObjectPHID($object_phid) 581 - ->setSequence(0); 583 + ->setSequence(0) 584 + ->setViewSequence($view_sequence++); 582 585 583 586 $this->addQueue[] = $new_position; 584 587
+20 -7
src/applications/project/storage/PhabricatorProjectColumnPosition.php
··· 9 9 protected $sequence; 10 10 11 11 private $column = self::ATTACHABLE; 12 + private $viewSequence = 0; 12 13 13 14 protected function getConfiguration() { 14 15 return array( ··· 40 41 return $this; 41 42 } 42 43 44 + public function setViewSequence($view_sequence) { 45 + $this->viewSequence = $view_sequence; 46 + return $this; 47 + } 48 + 43 49 public function getOrderingKey() { 44 - if (!$this->getID() && !$this->getSequence()) { 45 - return 0; 46 - } 50 + // We're ordering both real positions and "virtual" positions which we have 51 + // created but not saved yet. 47 52 48 - // Low sequence numbers go above high sequence numbers. 49 - // High position IDs go above low position IDs. 50 - // Broadly, this makes newly added stuff float to the top. 53 + // Low sequence numbers go above high sequence numbers. Virtual positions 54 + // will have sequence number 0. 55 + 56 + // High virtual sequence numbers go above low virtual sequence numbers. 57 + // The layout engine gets objects in ID order, and this puts them in 58 + // reverse ID order. 59 + 60 + // High IDs go above low IDs. 61 + 62 + // Broadly, this collectively makes newly added stuff float to the top. 51 63 52 64 return sprintf( 53 - '~%012d%012d', 65 + '~%012d%012d%012d', 54 66 $this->getSequence(), 67 + ((1 << 31) - $this->viewSequence), 55 68 ((1 << 31) - $this->getID())); 56 69 } 57 70