1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 16:52:41 +01:00

Fix an issues with moved Phriction documents if the old location does not exist or can't be loaded

Summary: Fixes T5250. This needs some general cleanup, but fix the fatal.

Test Plan:
  - Viewed moved document.
  - Viewed moved-from-nonexistent-source document.

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T5250

Differential Revision: https://secure.phabricator.com/D9357
This commit is contained in:
epriestley 2014-06-03 12:42:54 -07:00
parent 389a88d4bc
commit 75cbc3ef6c

View file

@ -75,7 +75,6 @@ final class PhrictionDocumentController
$vdate = phabricator_datetime($content->getDateCreated(), $user); $vdate = phabricator_datetime($content->getDateCreated(), $user);
$version_note = new AphrontErrorView(); $version_note = new AphrontErrorView();
$version_note->setSeverity(AphrontErrorView::SEVERITY_NOTICE); $version_note->setSeverity(AphrontErrorView::SEVERITY_NOTICE);
$version_note->setTitle('Older Version');
$version_note->appendChild( $version_note->appendChild(
pht('You are viewing an older version of this document, as it '. pht('You are viewing an older version of this document, as it '.
'appeared on %s.', $vdate)); 'appeared on %s.', $vdate));
@ -126,9 +125,8 @@ final class PhrictionDocumentController
$slug_uri = PhrictionDocument::getSlugURI($new_doc->getSlug()); $slug_uri = PhrictionDocument::getSlugURI($new_doc->getSlug());
} }
$notice = new AphrontErrorView(); $notice = id(new AphrontErrorView())
$notice->setSeverity(AphrontErrorView::SEVERITY_NOTICE); ->setSeverity(AphrontErrorView::SEVERITY_NOTICE);
$notice->setTitle(pht('Document Moved'));
if ($slug_uri) { if ($slug_uri) {
$notice->appendChild( $notice->appendChild(
@ -159,22 +157,33 @@ final class PhrictionDocumentController
$move_notice = null; $move_notice = null;
if ($current_status == PhrictionChangeType::CHANGE_MOVE_HERE) { if ($current_status == PhrictionChangeType::CHANGE_MOVE_HERE) {
$from_doc_id = $content->getChangeRef(); $from_doc_id = $content->getChangeRef();
$from_doc = id(new PhrictionDocumentQuery())
$slug_uri = null;
// If the old document exists and is visible, provide a link to it.
$from_docs = id(new PhrictionDocumentQuery())
->setViewer($user) ->setViewer($user)
->withIDs(array($from_doc_id)) ->withIDs(array($from_doc_id))
->executeOne(); ->execute();
if ($from_docs) {
$from_doc = head($from_docs);
$slug_uri = PhrictionDocument::getSlugURI($from_doc->getSlug()); $slug_uri = PhrictionDocument::getSlugURI($from_doc->getSlug());
}
$move_notice = id(new AphrontErrorView()) $move_notice = id(new AphrontErrorView())
->setSeverity(AphrontErrorView::SEVERITY_NOTICE) ->setSeverity(AphrontErrorView::SEVERITY_NOTICE);
->appendChild(pht('This document was moved from %s',
phutil_tag('a', array('href' => $slug_uri), $slug_uri)))
->render();
}
}
if ($version_note) { if ($slug_uri) {
$version_note = $version_note->render(); $move_notice->appendChild(
pht(
'This document was moved from %s.',
phutil_tag('a', array('href' => $slug_uri), $slug_uri)));
} else {
// Render this for consistency, even though it's a bit silly.
$move_notice->appendChild(
pht('This document was moved from elsewhere.'));
}
}
} }
$children = $this->renderDocumentChildren($slug); $children = $this->renderDocumentChildren($slug);
@ -204,6 +213,7 @@ final class PhrictionDocumentController
array( array(
$actions, $actions,
$prop_list, $prop_list,
$version_note,
$move_notice, $move_notice,
$core_content, $core_content,
)); ));