Page MenuHomePhabricator

D9254.diff
No OneTemporary

D9254.diff

diff --git a/src/applications/phriction/controller/PhrictionDocumentController.php b/src/applications/phriction/controller/PhrictionDocumentController.php
--- a/src/applications/phriction/controller/PhrictionDocumentController.php
+++ b/src/applications/phriction/controller/PhrictionDocumentController.php
@@ -112,20 +112,45 @@
$core_content = $notice->render();
} else if ($current_status == PhrictionChangeType::CHANGE_MOVE_AWAY) {
$new_doc_id = $content->getChangeRef();
- $new_doc = id(new PhrictionDocumentQuery())
+
+ $slug_uri = null;
+
+ // If the new document exists and the viewer can see it, provide a link
+ // to it. Otherwise, render a generic message.
+ $new_docs = id(new PhrictionDocumentQuery())
->setViewer($user)
->withIDs(array($new_doc_id))
- ->executeOne();
-
- $slug_uri = PhrictionDocument::getSlugURI($new_doc->getSlug());
+ ->execute();
+ if ($new_docs) {
+ $new_doc = head($new_docs);
+ $slug_uri = PhrictionDocument::getSlugURI($new_doc->getSlug());
+ }
$notice = new AphrontErrorView();
$notice->setSeverity(AphrontErrorView::SEVERITY_NOTICE);
$notice->setTitle(pht('Document Moved'));
- $notice->appendChild(phutil_tag('p', array(),
- pht('This document has been moved to %s. You can edit it to put new '.
- 'content here, or use history to revert to an earlier version.',
- phutil_tag('a', array('href' => $slug_uri), $slug_uri))));
+
+ if ($slug_uri) {
+ $notice->appendChild(
+ phutil_tag(
+ 'p',
+ array(),
+ pht(
+ 'This document has been moved to %s. You can edit it to put '.
+ 'new content here, or use history to revert to an earlier '.
+ 'version.',
+ phutil_tag('a', array('href' => $slug_uri), $slug_uri))));
+ } else {
+ $notice->appendChild(
+ phutil_tag(
+ 'p',
+ array(),
+ pht(
+ 'This document has been moved. You can edit it to put new '.
+ 'contne here, or use history to revert to an earlier '.
+ 'version.')));
+ }
+
$core_content = $notice->render();
} else {
throw new Exception("Unknown document status '{$doc_status}'!");

File Metadata

Mime Type
text/plain
Expires
Thu, Mar 20, 4:27 AM (2 d, 19 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7387240
Default Alt Text
D9254.diff (2 KB)

Event Timeline