@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 some transaction issues when retitling projects

Summary:
Fixes T5530.

- We currently fail if you rename a project so it has the same slug (e.g., "Example" -> "ExAmPlE").
- We currently fail if you rename a project so one of its secondary hashtags becomes the primary hashtag.

Instead, succeed in these cases.

Test Plan: Successfully performed the renames described above.

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T5458, T5530

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

+36 -11
+36 -11
src/applications/project/editor/PhabricatorProjectTransactionEditor.php
··· 106 106 PhabricatorLiskDAO $object, 107 107 PhabricatorApplicationTransaction $xaction) { 108 108 109 + $old = $xaction->getOldValue(); 110 + $new = $xaction->getNewValue(); 111 + 109 112 switch ($xaction->getTransactionType()) { 110 113 case PhabricatorProjectTransaction::TYPE_NAME: 114 + // First, remove the old and new slugs. Removing the old slug is 115 + // important when changing the project's capitalization or puctuation. 116 + // Removing the new slug is important when changing the project's name 117 + // so that one of its secondary slugs is now the primary slug. 118 + if ($old !== null) { 119 + $this->removeSlug($object, $old); 120 + } 121 + $this->removeSlug($object, $new); 122 + 111 123 $new_slug = id(new PhabricatorProjectSlug()) 112 124 ->setSlug($object->getPrimarySlug()) 113 125 ->setProjectPHID($object->getPHID()) 114 126 ->save(); 115 - 116 - if ($xaction->getOldValue() !== null) { 117 - $clone_object = clone $object; 118 - $clone_object->setPhrictionSlug($xaction->getOldValue()); 119 - $old_slug = $clone_object->getPrimarySlug(); 120 - $old_slug = id(new PhabricatorProjectSlug()) 121 - ->loadOneWhere('slug = %s', $old_slug); 122 - if ($old_slug) { 123 - $old_slug->delete(); 124 - } 125 - } 126 127 127 128 // TODO -- delete all of the below once we sever automagical project 128 129 // to phriction stuff ··· 427 428 } 428 429 429 430 return parent::extractFilePHIDsFromCustomTransaction($object, $xaction); 431 + } 432 + 433 + private function removeSlug( 434 + PhabricatorLiskDAO $object, 435 + $name) { 436 + 437 + $object = (clone $object); 438 + $object->setPhrictionSlug($name); 439 + $slug = $object->getPrimarySlug(); 440 + 441 + $slug_object = id(new PhabricatorProjectSlug())->loadOneWhere( 442 + 'slug = %s', 443 + $slug); 444 + 445 + if (!$slug_object) { 446 + return; 447 + } 448 + 449 + if ($slug_object->getProjectPHID() != $object->getPHID()) { 450 + throw new Exception( 451 + pht('Trying to remove slug owned by another project!')); 452 + } 453 + 454 + $slug_object->delete(); 430 455 } 431 456 432 457 }