@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 project editing issue with moving wikis

Summary: Fixes T4409. I didn't get this quite right when I updated it to ApplicationTransactions.

Test Plan: Renamed a project, saw wiki move.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T4409

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

+30 -27
+30 -27
src/applications/project/editor/PhabricatorProjectTransactionEditor.php
··· 55 55 switch ($xaction->getTransactionType()) { 56 56 case PhabricatorProjectTransaction::TYPE_NAME: 57 57 $object->setName($xaction->getNewValue()); 58 + $object->setPhrictionSlug($xaction->getNewValue()); 58 59 return; 59 60 case PhabricatorProjectTransaction::TYPE_STATUS: 60 61 $object->setStatus($xaction->getNewValue()); ··· 84 85 85 86 switch ($xaction->getTransactionType()) { 86 87 case PhabricatorProjectTransaction::TYPE_NAME: 87 - $old_slug = $object->getFullPhrictionSlug(); 88 - $object->setPhrictionSlug($xaction->getNewValue()); 89 - $changed_slug = $old_slug != $object->getFullPhrictionSlug(); 90 - if ($xaction->getOldValue() && $changed_slug) { 91 - $old_document = id(new PhrictionDocument()) 92 - ->loadOneWhere( 93 - 'slug = %s', 94 - $old_slug); 95 - if ($old_document && $old_document->getStatus() == 96 - PhrictionDocumentStatus::STATUS_EXISTS) { 97 - $content = id(new PhrictionContent()) 98 - ->load($old_document->getContentID()); 99 - $from_editor = id(PhrictionDocumentEditor::newForSlug($old_slug)) 100 - ->setActor($this->getActor()) 101 - ->setTitle($content->getTitle()) 102 - ->setContent($content->getContent()) 103 - ->setDescription($content->getDescription()); 88 + if ($xaction->getOldValue() === null) { 89 + // Project was just created, we don't need to move anything. 90 + return; 91 + } 92 + 93 + $clone_object = clone $object; 94 + $clone_object->setPhrictionSlug($xaction->getOldValue()); 95 + $old_slug = $clone_object->getFullPhrictionSlug(); 96 + 97 + $old_document = id(new PhrictionDocument()) 98 + ->loadOneWhere('slug = %s', $old_slug); 99 + if ($old_document && $old_document->getStatus() == 100 + PhrictionDocumentStatus::STATUS_EXISTS) { 101 + $content = id(new PhrictionContent()) 102 + ->load($old_document->getContentID()); 103 + $from_editor = id(PhrictionDocumentEditor::newForSlug($old_slug)) 104 + ->setActor($this->getActor()) 105 + ->setTitle($content->getTitle()) 106 + ->setContent($content->getContent()) 107 + ->setDescription($content->getDescription()); 104 108 105 - $target_editor = id(PhrictionDocumentEditor::newForSlug( 106 - $object->getFullPhrictionSlug())) 107 - ->setActor($this->getActor()) 108 - ->setTitle($content->getTitle()) 109 - ->setContent($content->getContent()) 110 - ->setDescription($content->getDescription()) 111 - ->moveHere($old_document->getID(), $old_document->getPHID()); 109 + $target_editor = id(PhrictionDocumentEditor::newForSlug( 110 + $object->getFullPhrictionSlug())) 111 + ->setActor($this->getActor()) 112 + ->setTitle($content->getTitle()) 113 + ->setContent($content->getContent()) 114 + ->setDescription($content->getDescription()) 115 + ->moveHere($old_document->getID(), $old_document->getPHID()); 112 116 113 - $target_document = $target_editor->getDocument(); 114 - $from_editor->moveAway($target_document->getID()); 115 - } 117 + $target_document = $target_editor->getDocument(); 118 + $from_editor->moveAway($target_document->getID()); 116 119 } 117 120 return; 118 121 case PhabricatorTransactions::TYPE_VIEW_POLICY: