@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 Phriction document move on to existing document placeholder

Summary:
Looks like the logic was there already but some minor parts were missing.
Fixes T8082.

Test Plan:
- Create document `/w/foo`
- Delete document `/w/foo`
- Create document `/w/bar`
- Move document `/w/bar` for `/w/foo`
No error was displayed and document `/w/bar` was moved to `/w/foo`.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Maniphest Tasks: T8082

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

authored by

Giedrius Dubinskas and committed by
gd
4e831e78 dad17fb9

+25 -11
+16 -4
src/applications/phriction/controller/PhrictionMoveController.php
··· 31 31 if ($request->isFormPost()) { 32 32 $v_note = $request->getStr('description'); 33 33 $v_slug = $request->getStr('slug'); 34 + $normal_slug = PhabricatorSlug::normalize($v_slug); 34 35 35 36 // If what the user typed isn't what we're actually using, warn them 36 37 // about it. 37 38 if (strlen($v_slug)) { 38 - $normal_slug = PhabricatorSlug::normalize($v_slug); 39 39 $no_slash_slug = rtrim($normal_slug, '/'); 40 40 if ($normal_slug !== $v_slug && $no_slash_slug !== $v_slug) { 41 41 return $this->newDialog() ··· 66 66 $xactions[] = id(new PhrictionTransaction()) 67 67 ->setTransactionType(PhrictionTransaction::TYPE_MOVE_TO) 68 68 ->setNewValue($document); 69 - $target_document = PhrictionDocument::initializeNewDocument( 70 - $viewer, 71 - $v_slug); 69 + $target_document = id(new PhrictionDocumentQuery()) 70 + ->setViewer(PhabricatorUser::getOmnipotentUser()) 71 + ->withSlugs(array($normal_slug)) 72 + ->needContent(true) 73 + ->requireCapabilities( 74 + array( 75 + PhabricatorPolicyCapability::CAN_VIEW, 76 + PhabricatorPolicyCapability::CAN_EDIT, 77 + )) 78 + ->executeOne(); 79 + if (!$target_document) { 80 + $target_document = PhrictionDocument::initializeNewDocument( 81 + $viewer, 82 + $v_slug); 83 + } 72 84 try { 73 85 $editor->applyTransactions($target_document, $xactions); 74 86 $redir_uri = PhrictionDocument::getSlugURI(
+9 -7
src/applications/phriction/editor/PhrictionTransactionEditor.php
··· 588 588 // Prevent overwrites and no-op moves. 589 589 $exists = PhrictionDocumentStatus::STATUS_EXISTS; 590 590 if ($target_document) { 591 + $message = null; 591 592 if ($target_document->getSlug() == $source_document->getSlug()) { 592 593 $message = pht( 593 594 'You can not move a document to its existing location. '. ··· 598 599 'overwrite an existing document which is already at that '. 599 600 'location. Move or delete the existing document first.'); 600 601 } 601 - 602 - $error = new PhabricatorApplicationTransactionValidationError( 603 - $type, 604 - pht('Invalid'), 605 - $message, 606 - $xaction); 607 - $errors[] = $error; 602 + if ($message !== null) { 603 + $error = new PhabricatorApplicationTransactionValidationError( 604 + $type, 605 + pht('Invalid'), 606 + $message, 607 + $xaction); 608 + $errors[] = $error; 609 + } 608 610 } 609 611 break; 610 612