From 8dd4d5cfe5e6bf848687b2907c66211ca7b1be59 Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Wed, 20 Aug 2014 13:18:21 -0700 Subject: [PATCH] Files - make file info page public Summary: and for bonus, finesse some URIs a tad. Fixes T5922. Test Plan: viewed F1 logged out and it worked! viewed the ugly URI for F1 and got redirected to the pretty URI. Reviewers: epriestley Reviewed By: epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T5922 Differential Revision: https://secure.phabricator.com/D10309 --- src/__phutil_library_map__.php | 2 -- .../PhabricatorFilesApplication.php | 2 +- .../PhabricatorFileInfoController.php | 22 ++++++++++++++--- .../PhabricatorFileShortcutController.php | 24 ------------------- .../files/storage/PhabricatorFile.php | 2 +- 5 files changed, 21 insertions(+), 31 deletions(-) delete mode 100644 src/applications/files/controller/PhabricatorFileShortcutController.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index df5fc2c4f4..99d372b7d0 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1557,7 +1557,6 @@ phutil_register_library_map(array( 'PhabricatorFileListController' => 'applications/files/controller/PhabricatorFileListController.php', 'PhabricatorFileQuery' => 'applications/files/query/PhabricatorFileQuery.php', 'PhabricatorFileSearchEngine' => 'applications/files/query/PhabricatorFileSearchEngine.php', - 'PhabricatorFileShortcutController' => 'applications/files/controller/PhabricatorFileShortcutController.php', 'PhabricatorFileStorageBlob' => 'applications/files/storage/PhabricatorFileStorageBlob.php', 'PhabricatorFileStorageConfigurationException' => 'applications/files/exception/PhabricatorFileStorageConfigurationException.php', 'PhabricatorFileStorageEngine' => 'applications/files/engine/PhabricatorFileStorageEngine.php', @@ -4406,7 +4405,6 @@ phutil_register_library_map(array( 'PhabricatorFileListController' => 'PhabricatorFileController', 'PhabricatorFileQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorFileSearchEngine' => 'PhabricatorApplicationSearchEngine', - 'PhabricatorFileShortcutController' => 'PhabricatorFileController', 'PhabricatorFileStorageBlob' => 'PhabricatorFileDAO', 'PhabricatorFileStorageConfigurationException' => 'Exception', 'PhabricatorFileTemporaryGarbageCollector' => 'PhabricatorGarbageCollector', diff --git a/src/applications/files/application/PhabricatorFilesApplication.php b/src/applications/files/application/PhabricatorFilesApplication.php index e19ab58b48..eb1a5a4db8 100644 --- a/src/applications/files/application/PhabricatorFilesApplication.php +++ b/src/applications/files/application/PhabricatorFilesApplication.php @@ -42,7 +42,7 @@ final class PhabricatorFilesApplication extends PhabricatorApplication { public function getRoutes() { return array( - '/F(?P[1-9]\d*)' => 'PhabricatorFileShortcutController', + '/F(?P[1-9]\d*)' => 'PhabricatorFileInfoController', '/file/' => array( '(query/(?P[^/]+)/)?' => 'PhabricatorFileListController', 'upload/' => 'PhabricatorFileUploadController', diff --git a/src/applications/files/controller/PhabricatorFileInfoController.php b/src/applications/files/controller/PhabricatorFileInfoController.php index 1e058e3762..bcf513390c 100644 --- a/src/applications/files/controller/PhabricatorFileInfoController.php +++ b/src/applications/files/controller/PhabricatorFileInfoController.php @@ -3,20 +3,36 @@ final class PhabricatorFileInfoController extends PhabricatorFileController { private $phid; + private $id; + + public function shouldAllowPublic() { + return true; + } public function willProcessRequest(array $data) { - $this->phid = $data['phid']; + $this->phid = idx($data, 'phid'); + $this->id = idx($data, 'id'); } public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); + if ($this->phid) { + $file = id(new PhabricatorFileQuery()) + ->setViewer($user) + ->withPHIDs(array($this->phid)) + ->executeOne(); + + if (!$file) { + return new Aphront404Response(); + } + return id(new AphrontRedirectResponse())->setURI($file->getInfoURI()); + } $file = id(new PhabricatorFileQuery()) ->setViewer($user) - ->withPHIDs(array($this->phid)) + ->withIDs(array($this->id)) ->executeOne(); - if (!$file) { return new Aphront404Response(); } diff --git a/src/applications/files/controller/PhabricatorFileShortcutController.php b/src/applications/files/controller/PhabricatorFileShortcutController.php deleted file mode 100644 index 922482f197..0000000000 --- a/src/applications/files/controller/PhabricatorFileShortcutController.php +++ /dev/null @@ -1,24 +0,0 @@ -id = $data['id']; - } - - public function processRequest() { - $file = id(new PhabricatorFileQuery()) - ->setViewer($this->getRequest()->getUser()) - ->withIDs(array($this->id)) - ->executeOne(); - if (!$file) { - return new Aphront404Response(); - } - - return id(new AphrontRedirectResponse())->setURI($file->getInfoURI()); - } - -} diff --git a/src/applications/files/storage/PhabricatorFile.php b/src/applications/files/storage/PhabricatorFile.php index fe4e061955..217c39bc47 100644 --- a/src/applications/files/storage/PhabricatorFile.php +++ b/src/applications/files/storage/PhabricatorFile.php @@ -495,7 +495,7 @@ final class PhabricatorFile extends PhabricatorFileDAO } public function getInfoURI() { - return '/file/info/'.$this->getPHID().'/'; + return '/'.$this->getMonogram(); } public function getBestURI() {