mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-30 01:10:58 +01:00
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
This commit is contained in:
parent
8739ea4dc1
commit
3a01d6dae5
1 changed files with 30 additions and 27 deletions
|
@ -55,6 +55,7 @@ final class PhabricatorProjectTransactionEditor
|
||||||
switch ($xaction->getTransactionType()) {
|
switch ($xaction->getTransactionType()) {
|
||||||
case PhabricatorProjectTransaction::TYPE_NAME:
|
case PhabricatorProjectTransaction::TYPE_NAME:
|
||||||
$object->setName($xaction->getNewValue());
|
$object->setName($xaction->getNewValue());
|
||||||
|
$object->setPhrictionSlug($xaction->getNewValue());
|
||||||
return;
|
return;
|
||||||
case PhabricatorProjectTransaction::TYPE_STATUS:
|
case PhabricatorProjectTransaction::TYPE_STATUS:
|
||||||
$object->setStatus($xaction->getNewValue());
|
$object->setStatus($xaction->getNewValue());
|
||||||
|
@ -84,35 +85,37 @@ final class PhabricatorProjectTransactionEditor
|
||||||
|
|
||||||
switch ($xaction->getTransactionType()) {
|
switch ($xaction->getTransactionType()) {
|
||||||
case PhabricatorProjectTransaction::TYPE_NAME:
|
case PhabricatorProjectTransaction::TYPE_NAME:
|
||||||
$old_slug = $object->getFullPhrictionSlug();
|
if ($xaction->getOldValue() === null) {
|
||||||
$object->setPhrictionSlug($xaction->getNewValue());
|
// Project was just created, we don't need to move anything.
|
||||||
$changed_slug = $old_slug != $object->getFullPhrictionSlug();
|
return;
|
||||||
if ($xaction->getOldValue() && $changed_slug) {
|
}
|
||||||
$old_document = id(new PhrictionDocument())
|
|
||||||
->loadOneWhere(
|
|
||||||
'slug = %s',
|
|
||||||
$old_slug);
|
|
||||||
if ($old_document && $old_document->getStatus() ==
|
|
||||||
PhrictionDocumentStatus::STATUS_EXISTS) {
|
|
||||||
$content = id(new PhrictionContent())
|
|
||||||
->load($old_document->getContentID());
|
|
||||||
$from_editor = id(PhrictionDocumentEditor::newForSlug($old_slug))
|
|
||||||
->setActor($this->getActor())
|
|
||||||
->setTitle($content->getTitle())
|
|
||||||
->setContent($content->getContent())
|
|
||||||
->setDescription($content->getDescription());
|
|
||||||
|
|
||||||
$target_editor = id(PhrictionDocumentEditor::newForSlug(
|
$clone_object = clone $object;
|
||||||
$object->getFullPhrictionSlug()))
|
$clone_object->setPhrictionSlug($xaction->getOldValue());
|
||||||
->setActor($this->getActor())
|
$old_slug = $clone_object->getFullPhrictionSlug();
|
||||||
->setTitle($content->getTitle())
|
|
||||||
->setContent($content->getContent())
|
|
||||||
->setDescription($content->getDescription())
|
|
||||||
->moveHere($old_document->getID(), $old_document->getPHID());
|
|
||||||
|
|
||||||
$target_document = $target_editor->getDocument();
|
$old_document = id(new PhrictionDocument())
|
||||||
$from_editor->moveAway($target_document->getID());
|
->loadOneWhere('slug = %s', $old_slug);
|
||||||
}
|
if ($old_document && $old_document->getStatus() ==
|
||||||
|
PhrictionDocumentStatus::STATUS_EXISTS) {
|
||||||
|
$content = id(new PhrictionContent())
|
||||||
|
->load($old_document->getContentID());
|
||||||
|
$from_editor = id(PhrictionDocumentEditor::newForSlug($old_slug))
|
||||||
|
->setActor($this->getActor())
|
||||||
|
->setTitle($content->getTitle())
|
||||||
|
->setContent($content->getContent())
|
||||||
|
->setDescription($content->getDescription());
|
||||||
|
|
||||||
|
$target_editor = id(PhrictionDocumentEditor::newForSlug(
|
||||||
|
$object->getFullPhrictionSlug()))
|
||||||
|
->setActor($this->getActor())
|
||||||
|
->setTitle($content->getTitle())
|
||||||
|
->setContent($content->getContent())
|
||||||
|
->setDescription($content->getDescription())
|
||||||
|
->moveHere($old_document->getID(), $old_document->getPHID());
|
||||||
|
|
||||||
|
$target_document = $target_editor->getDocument();
|
||||||
|
$from_editor->moveAway($target_document->getID());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
||||||
|
|
Loading…
Reference in a new issue