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

Don't fatal when viewing a moved document if the target does not exist or isn't visible

Summary: Fixes T5156. If a document has been moved but the new one does not exist or can't be seen by the viewer, render a generic message.

Test Plan: Viewed moved-plus-visible and moved-plus-nonvisible documents.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T5156

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

+33 -8
+33 -8
src/applications/phriction/controller/PhrictionDocumentController.php
··· 112 112 $core_content = $notice->render(); 113 113 } else if ($current_status == PhrictionChangeType::CHANGE_MOVE_AWAY) { 114 114 $new_doc_id = $content->getChangeRef(); 115 - $new_doc = id(new PhrictionDocumentQuery()) 115 + 116 + $slug_uri = null; 117 + 118 + // If the new document exists and the viewer can see it, provide a link 119 + // to it. Otherwise, render a generic message. 120 + $new_docs = id(new PhrictionDocumentQuery()) 116 121 ->setViewer($user) 117 122 ->withIDs(array($new_doc_id)) 118 - ->executeOne(); 119 - 120 - $slug_uri = PhrictionDocument::getSlugURI($new_doc->getSlug()); 123 + ->execute(); 124 + if ($new_docs) { 125 + $new_doc = head($new_docs); 126 + $slug_uri = PhrictionDocument::getSlugURI($new_doc->getSlug()); 127 + } 121 128 122 129 $notice = new AphrontErrorView(); 123 130 $notice->setSeverity(AphrontErrorView::SEVERITY_NOTICE); 124 131 $notice->setTitle(pht('Document Moved')); 125 - $notice->appendChild(phutil_tag('p', array(), 126 - pht('This document has been moved to %s. You can edit it to put new '. 127 - 'content here, or use history to revert to an earlier version.', 128 - phutil_tag('a', array('href' => $slug_uri), $slug_uri)))); 132 + 133 + if ($slug_uri) { 134 + $notice->appendChild( 135 + phutil_tag( 136 + 'p', 137 + array(), 138 + pht( 139 + 'This document has been moved to %s. You can edit it to put '. 140 + 'new content here, or use history to revert to an earlier '. 141 + 'version.', 142 + phutil_tag('a', array('href' => $slug_uri), $slug_uri)))); 143 + } else { 144 + $notice->appendChild( 145 + phutil_tag( 146 + 'p', 147 + array(), 148 + pht( 149 + 'This document has been moved. You can edit it to put new '. 150 + 'contne here, or use history to revert to an earlier '. 151 + 'version.'))); 152 + } 153 + 129 154 $core_content = $notice->render(); 130 155 } else { 131 156 throw new Exception("Unknown document status '{$doc_status}'!");