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

Cover redirects to files in more cases

Summary: Ref T5894. We have a couple more similar cases. Make them all do a decision-based redirect for now.

Test Plan: Did "View Raw File" and such, and also made sure thumbnails still work.

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T5894

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

+25 -20
+1
src/__phutil_library_map__.php
··· 4381 4381 'PhabricatorSubscribableInterface', 4382 4382 'PhabricatorFlaggableInterface', 4383 4383 'PhabricatorPolicyInterface', 4384 + 'PhabricatorDestructibleInterface', 4384 4385 ), 4385 4386 'PhabricatorFileCommentController' => 'PhabricatorFileController', 4386 4387 'PhabricatorFileComposeController' => 'PhabricatorFileController',
+1 -2
src/applications/differential/controller/DifferentialChangesetViewController.php
··· 347 347 unset($unguard); 348 348 } 349 349 350 - return id(new AphrontRedirectResponse()) 351 - ->setURI($file->getBestURI()); 350 + return $file->getRedirectResponse(); 352 351 } 353 352 354 353 private function buildLintInlineComments($changeset) {
+1 -1
src/applications/differential/controller/DifferentialRevisionViewController.php
··· 918 918 $revision->getPHID()); 919 919 unset($unguarded); 920 920 921 - return id(new AphrontRedirectResponse())->setURI($file->getBestURI()); 921 + return $file->getRedirectResponse(); 922 922 } 923 923 924 924 private function buildTransactions(
+1 -1
src/applications/diffusion/controller/DiffusionBrowseFileController.php
··· 887 887 888 888 private function buildRawResponse($path, $data) { 889 889 $file = $this->loadFileForData($path, $data); 890 - return id(new AphrontRedirectResponse())->setURI($file->getBestURI()); 890 + return $file->getRedirectResponse(); 891 891 } 892 892 893 893 private function buildImageCorpus($file_uri) {
+1 -1
src/applications/diffusion/controller/DiffusionCommitController.php
··· 1042 1042 $drequest->getRepository()->getPHID()); 1043 1043 unset($unguarded); 1044 1044 1045 - return id(new AphrontRedirectResponse())->setURI($file->getBestURI()); 1045 + return $file->getRedirectResponse(); 1046 1046 } 1047 1047 1048 1048 private function renderAuditStatusView(array $audit_requests) {
+1 -15
src/applications/files/controller/PhabricatorFileTransformController.php
··· 148 148 149 149 // TODO: We could just delegate to the file view controller instead, 150 150 // which would save the client a roundtrip, but is slightly more complex. 151 - $uri = $file->getBestURI(); 152 151 153 - // TODO: This is a bit iffy. Sometimes, getBestURI() returns a CDN URI 154 - // (if the file is a viewable image) and sometimes a local URI (if not). 155 - // For now, just detect which one we got and configure the response 156 - // appropriately. In the long run, if this endpoint is served from a CDN 157 - // domain, we can't issue a local redirect to an info URI (which is not 158 - // present on the CDN domain). We probably never actually issue local 159 - // redirects here anyway, since we only ever transform viewable images 160 - // right now. 161 - 162 - $is_external = strlen(id(new PhutilURI($uri))->getDomain()); 163 - 164 - return id(new AphrontRedirectResponse()) 165 - ->setIsExternal($is_external) 166 - ->setURI($uri); 152 + return $file->getRedirectResponse(); 167 153 } 168 154 169 155 private function executePreviewTransform(PhabricatorFile $file, $size) {
+19
src/applications/files/storage/PhabricatorFile.php
··· 967 967 return $this; 968 968 } 969 969 970 + public function getRedirectResponse() { 971 + $uri = $this->getBestURI(); 972 + 973 + // TODO: This is a bit iffy. Sometimes, getBestURI() returns a CDN URI 974 + // (if the file is a viewable image) and sometimes a local URI (if not). 975 + // For now, just detect which one we got and configure the response 976 + // appropriately. In the long run, if this endpoint is served from a CDN 977 + // domain, we can't issue a local redirect to an info URI (which is not 978 + // present on the CDN domain). We probably never actually issue local 979 + // redirects here anyway, since we only ever transform viewable images 980 + // right now. 981 + 982 + $is_external = strlen(id(new PhutilURI($uri))->getDomain()); 983 + 984 + return id(new AphrontRedirectResponse()) 985 + ->setIsExternal($is_external) 986 + ->setURI($uri); 987 + } 988 + 970 989 971 990 /* -( PhabricatorPolicyInterface Implementation )-------------------------- */ 972 991