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

When a task is removed from projects, remove its position on proxy columns for those projects

Summary:
Fixes T11088. When a task is removed from a project, we don't normally delete its column positions. If you accidentally remove a project and then restore the project, it's nice for the task to stay where you put it.

However, we do need to remove its positions in proxy columns to avoid the issue in T11088.

Test Plan:
- Added a failing unit test, made it pass.
- Added a task to "X > Milestone 1", loaded workboard, used "Edit Projects" to move it to "X" instead, loaded workboard.
- Before, it stayed in the "Milestone 1" column.
- After, it moves to the "Backlog" column.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11088

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

+61
+15
src/applications/project/__tests__/PhabricatorProjectCoreTestCase.php
··· 1044 1044 $this->moveToColumn($user, $board, $task_a, $column, $column, $a_options); 1045 1045 $new_projects = $this->getTaskProjects($task_a); 1046 1046 $this->assertEqual($old_projects, $new_projects); 1047 + 1048 + 1049 + // Add the parent project to the task. This should move it out of the 1050 + // milestone column and into the parent's backlog. 1051 + $this->addProjectTags($user, $task, array($board->getPHID())); 1052 + $expect_columns = array( 1053 + $backlog->getPHID(), 1054 + ); 1055 + $this->assertColumns($expect_columns, $user, $board, $task); 1056 + 1057 + $new_projects = $this->getTaskProjects($task); 1058 + $expect_projects = array( 1059 + $board->getPHID(), 1060 + ); 1061 + $this->assertEqual($expect_projects, $new_projects); 1047 1062 } 1048 1063 1049 1064 public function testColumnExtendedPolicies() {
+46
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
··· 677 677 } 678 678 679 679 $editor->save(); 680 + 681 + $this->updateWorkboardColumns($object, $const, $old, $new); 680 682 break; 681 683 case PhabricatorTransactions::TYPE_VIEW_POLICY: 682 684 case PhabricatorTransactions::TYPE_SPACE: ··· 3602 3604 3603 3605 return true; 3604 3606 } 3607 + 3608 + private function updateWorkboardColumns($object, $const, $old, $new) { 3609 + // If an object is removed from a project, remove it from any proxy 3610 + // columns for that project. This allows a task which is moved up from a 3611 + // milestone to the parent to move back into the "Backlog" column on the 3612 + // parent workboard. 3613 + 3614 + if ($const != PhabricatorProjectObjectHasProjectEdgeType::EDGECONST) { 3615 + return; 3616 + } 3617 + 3618 + // TODO: This should likely be some future WorkboardInterface. 3619 + $appears_on_workboards = ($object instanceof ManiphestTask); 3620 + if (!$appears_on_workboards) { 3621 + return; 3622 + } 3623 + 3624 + $removed_phids = array_keys(array_diff_key($old, $new)); 3625 + if (!$removed_phids) { 3626 + return; 3627 + } 3628 + 3629 + // Find any proxy columns for the removed projects. 3630 + $proxy_columns = id(new PhabricatorProjectColumnQuery()) 3631 + ->setViewer(PhabricatorUser::getOmnipotentUser()) 3632 + ->withProxyPHIDs($removed_phids) 3633 + ->execute(); 3634 + if (!$proxy_columns) { 3635 + return array(); 3636 + } 3637 + 3638 + $proxy_phids = mpull($proxy_columns, 'getPHID'); 3639 + 3640 + $position_table = new PhabricatorProjectColumnPosition(); 3641 + $conn_w = $position_table->establishConnection('w'); 3642 + 3643 + queryfx( 3644 + $conn_w, 3645 + 'DELETE FROM %T WHERE objectPHID = %s AND columnPHID IN (%Ls)', 3646 + $position_table->getTableName(), 3647 + $object->getPHID(), 3648 + $proxy_phids); 3649 + } 3650 + 3605 3651 3606 3652 }