diff --git a/src/applications/phriction/controller/document/PhrictionDocumentController.php b/src/applications/phriction/controller/document/PhrictionDocumentController.php
index 3da625f360..1a99de9cb2 100644
--- a/src/applications/phriction/controller/document/PhrictionDocumentController.php
+++ b/src/applications/phriction/controller/document/PhrictionDocumentController.php
@@ -50,21 +50,25 @@ final class PhrictionDocumentController
$version_note = null;
if (!$document) {
- $create_uri = '/phriction/edit/?slug='.$slug;
- $page_content =
- '
'.
- 'No content here!
'.
- 'No document found at '.phutil_escape_html($slug).'. '.
- 'You can '.
- phutil_render_tag(
- 'a',
- array(
- 'href' => $create_uri,
- ),
- 'create a new document').'.'.
- '
';
- $page_title = 'Page Not Found';
+ if (PhrictionDocument::isProjectSlug($slug)) {
+ $project = id(new PhabricatorProject())->loadOneWhere(
+ 'phrictionSlug = %s',
+ PhrictionDocument::getProjectSlugIdentifier($slug));
+ if (!$project) {
+ return new Aphront404Response();
+ }
+ }
+ $create_uri = '/phriction/edit/?slug='.$slug;
+ $create_sentence =
+ 'You can '.
+ phutil_render_tag(
+ 'a',
+ array(
+ 'href' => $create_uri,
+ ),
+ 'create a new document').
+ '.';
$button = phutil_render_tag(
'a',
array(
@@ -72,6 +76,14 @@ final class PhrictionDocumentController
'class' => 'green button',
),
'Create Page');
+
+ $page_content =
+ ''.
+ 'No content here!
'.
+ 'No document found at '.phutil_escape_html($slug).'. '.
+ $create_sentence.
+ '
';
+ $page_title = 'Page Not Found';
$buttons = $button;
} else {
$version = $request->getInt('v');
diff --git a/src/applications/phriction/controller/edit/PhrictionEditController.php b/src/applications/phriction/controller/edit/PhrictionEditController.php
index fafd42bb8c..d896169b0a 100644
--- a/src/applications/phriction/controller/edit/PhrictionEditController.php
+++ b/src/applications/phriction/controller/edit/PhrictionEditController.php
@@ -66,6 +66,14 @@ final class PhrictionEditController
if ($document) {
$content = id(new PhrictionContent())->load($document->getContentID());
} else {
+ if (PhrictionDocument::isProjectSlug($slug)) {
+ $project = id(new PhabricatorProject())->loadOneWhere(
+ 'phrictionSlug = %s',
+ PhrictionDocument::getProjectSlugIdentifier($slug));
+ if (!$project) {
+ return new Aphront404Response();
+ }
+ }
$document = new PhrictionDocument();
$document->setSlug($slug);
diff --git a/src/applications/phriction/controller/edit/__init__.php b/src/applications/phriction/controller/edit/__init__.php
index ba786145d3..11224e2536 100644
--- a/src/applications/phriction/controller/edit/__init__.php
+++ b/src/applications/phriction/controller/edit/__init__.php
@@ -13,6 +13,7 @@ phutil_require_module('phabricator', 'applications/phriction/controller/base');
phutil_require_module('phabricator', 'applications/phriction/editor/document');
phutil_require_module('phabricator', 'applications/phriction/storage/content');
phutil_require_module('phabricator', 'applications/phriction/storage/document');
+phutil_require_module('phabricator', 'applications/project/storage/project');
phutil_require_module('phabricator', 'infrastructure/celerity/api');
phutil_require_module('phabricator', 'infrastructure/env');
phutil_require_module('phabricator', 'infrastructure/javelin/api');