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

Remove unused file transforms

Summary:
Ref T7707.

- Modernize the file transform endpoint a bit.
- Delete transforms which are no longer used in the product.

Test Plan:
- Used Pholio (navigation, inline thumbs).
- Uploaded images (embed thumb).
- Changed profile picture (profile thumb).

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7707

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

+20 -101
-2
src/__phutil_library_map__.php
··· 2824 2824 'PholioImageUploadController' => 'applications/pholio/controller/PholioImageUploadController.php', 2825 2825 'PholioInlineController' => 'applications/pholio/controller/PholioInlineController.php', 2826 2826 'PholioInlineListController' => 'applications/pholio/controller/PholioInlineListController.php', 2827 - 'PholioInlineThumbController' => 'applications/pholio/controller/PholioInlineThumbController.php', 2828 2827 'PholioMock' => 'applications/pholio/storage/PholioMock.php', 2829 2828 'PholioMockCommentController' => 'applications/pholio/controller/PholioMockCommentController.php', 2830 2829 'PholioMockEditController' => 'applications/pholio/controller/PholioMockEditController.php', ··· 6311 6310 'PholioImageUploadController' => 'PholioController', 6312 6311 'PholioInlineController' => 'PholioController', 6313 6312 'PholioInlineListController' => 'PholioController', 6314 - 'PholioInlineThumbController' => 'PholioController', 6315 6313 'PholioMock' => array( 6316 6314 'PholioDAO', 6317 6315 'PhabricatorMarkupInterface',
+20 -40
src/applications/files/controller/PhabricatorFileTransformController.php
··· 3 3 final class PhabricatorFileTransformController 4 4 extends PhabricatorFileController { 5 5 6 - private $transform; 7 - private $phid; 8 - private $key; 9 - 10 6 public function shouldRequireLogin() { 11 7 return false; 12 8 } 13 9 14 - public function willProcessRequest(array $data) { 15 - $this->transform = $data['transform']; 16 - $this->phid = $data['phid']; 17 - $this->key = $data['key']; 18 - } 19 - 20 - public function processRequest() { 21 - $viewer = $this->getRequest()->getUser(); 10 + public function handleRequest(AphrontRequest $request) { 11 + $viewer = $this->getViewer(); 22 12 23 13 // NOTE: This is a public/CDN endpoint, and permission to see files is 24 14 // controlled by knowing the secret key, not by authentication. 25 15 16 + $source_phid = $request->getURIData('phid'); 26 17 $file = id(new PhabricatorFileQuery()) 27 18 ->setViewer(PhabricatorUser::getOmnipotentUser()) 28 - ->withPHIDs(array($this->phid)) 19 + ->withPHIDs(array($source_phid)) 29 20 ->executeOne(); 30 21 if (!$file) { 31 22 return new Aphront404Response(); 32 23 } 33 24 34 - if (!$file->validateSecretKey($this->key)) { 25 + $secret_key = $request->getURIData('key'); 26 + if (!$file->validateSecretKey($secret_key)) { 35 27 return new Aphront403Response(); 36 28 } 37 29 30 + $transform = $request->getURIData('transform'); 38 31 $xform = id(new PhabricatorTransformedFile()) 39 32 ->loadOneWhere( 40 33 'originalPHID = %s AND transform = %s', 41 - $this->phid, 42 - $this->transform); 34 + $source_phid, 35 + $transform); 43 36 44 37 if ($xform) { 45 38 return $this->buildTransformedFileResponse($xform); ··· 48 41 $type = $file->getMimeType(); 49 42 50 43 if (!$file->isViewableInBrowser() || !$file->isTransformableImage()) { 51 - return $this->buildDefaultTransformation($file); 44 + return $this->buildDefaultTransformation($file, $transform); 52 45 } 53 46 54 47 // We're essentially just building a cache here and don't need CSRF 55 48 // protection. 56 49 $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); 57 50 58 - switch ($this->transform) { 51 + switch ($transform) { 59 52 case 'thumb-profile': 60 53 $xformed_file = $this->executeThumbTransform($file, 50, 50); 61 54 break; 62 55 case 'thumb-280x210': 63 56 $xformed_file = $this->executeThumbTransform($file, 280, 210); 64 57 break; 65 - case 'thumb-220x165': 66 - $xformed_file = $this->executeThumbTransform($file, 220, 165); 67 - break; 68 58 case 'preview-100': 69 59 $xformed_file = $this->executePreviewTransform($file, 100); 70 60 break; 71 61 case 'preview-220': 72 62 $xformed_file = $this->executePreviewTransform($file, 220); 73 - break; 74 - case 'thumb-160x120': 75 - $xformed_file = $this->executeThumbTransform($file, 160, 120); 76 - break; 77 - case 'thumb-60x45': 78 - $xformed_file = $this->executeThumbTransform($file, 60, 45); 79 63 break; 80 64 default: 81 65 return new Aphront400Response(); ··· 85 69 return new Aphront400Response(); 86 70 } 87 71 88 - $xform = new PhabricatorTransformedFile(); 89 - $xform->setOriginalPHID($this->phid); 90 - $xform->setTransform($this->transform); 91 - $xform->setTransformedPHID($xformed_file->getPHID()); 92 - $xform->save(); 72 + $xform = id(new PhabricatorTransformedFile()) 73 + ->setOriginalPHID($source_phid) 74 + ->setTransform($transform) 75 + ->setTransformedPHID($xformed_file->getPHID()) 76 + ->save(); 93 77 94 78 return $this->buildTransformedFileResponse($xform); 95 79 } 96 80 97 - private function buildDefaultTransformation(PhabricatorFile $file) { 81 + private function buildDefaultTransformation( 82 + PhabricatorFile $file, 83 + $transform) { 98 84 static $regexps = array( 99 85 '@application/zip@' => 'zip', 100 86 '@image/@' => 'image', ··· 111 97 } 112 98 } 113 99 114 - switch ($this->transform) { 100 + switch ($transform) { 115 101 case 'thumb-280x210': 116 102 $suffix = '280x210'; 117 - break; 118 - case 'thumb-160x120': 119 - $suffix = '160x120'; 120 - break; 121 - case 'thumb-60x45': 122 - $suffix = '60x45'; 123 103 break; 124 104 case 'preview-100': 125 105 $suffix = '.p100';
-12
src/applications/files/storage/PhabricatorFile.php
··· 784 784 return $this->getTransformedURI('thumb-profile'); 785 785 } 786 786 787 - public function getThumb60x45URI() { 788 - return $this->getTransformedURI('thumb-60x45'); 789 - } 790 - 791 - public function getThumb160x120URI() { 792 - return $this->getTransformedURI('thumb-160x120'); 793 - } 794 - 795 787 public function getPreview100URI() { 796 788 return $this->getTransformedURI('preview-100'); 797 789 } 798 790 799 791 public function getPreview220URI() { 800 792 return $this->getTransformedURI('preview-220'); 801 - } 802 - 803 - public function getThumb220x165URI() { 804 - return $this->getTransfomredURI('thumb-220x165'); 805 793 } 806 794 807 795 public function getThumb280x210URI() {
-1
src/applications/pholio/application/PhabricatorPholioApplication.php
··· 49 49 'inline/' => array( 50 50 '(?:(?P<id>\d+)/)?' => 'PholioInlineController', 51 51 'list/(?P<id>\d+)/' => 'PholioInlineListController', 52 - 'thumb/(?P<imageid>\d+)/' => 'PholioInlineThumbController', 53 52 ), 54 53 'image/' => array( 55 54 'upload/' => 'PholioImageUploadController',
-46
src/applications/pholio/controller/PholioInlineThumbController.php
··· 1 - <?php 2 - 3 - final class PholioInlineThumbController extends PholioController { 4 - 5 - private $imageid; 6 - 7 - public function shouldAllowPublic() { 8 - return true; 9 - } 10 - 11 - public function willProcessRequest(array $data) { 12 - $this->imageid = idx($data, 'imageid'); 13 - } 14 - 15 - public function processRequest() { 16 - $request = $this->getRequest(); 17 - $user = $request->getUser(); 18 - 19 - $image = id(new PholioImage())->load($this->imageid); 20 - 21 - if ($image == null) { 22 - return new Aphront404Response(); 23 - } 24 - 25 - $mock = id(new PholioMockQuery()) 26 - ->setViewer($user) 27 - ->withIDs(array($image->getMockID())) 28 - ->executeOne(); 29 - 30 - if (!$mock) { 31 - return new Aphront404Response(); 32 - } 33 - 34 - $file = id(new PhabricatorFileQuery()) 35 - ->setViewer($user) 36 - ->witHPHIDs(array($image->getFilePHID())) 37 - ->executeOne(); 38 - 39 - if (!$file) { 40 - return new Aphront404Response(); 41 - } 42 - 43 - return id(new AphrontRedirectResponse())->setURI($file->getThumb60x45URI()); 44 - } 45 - 46 - }
webroot/rsrc/image/icon/fatcow/thumbnails/default160x120.png

This is a binary file and will not be displayed.

webroot/rsrc/image/icon/fatcow/thumbnails/default60x45.png

This is a binary file and will not be displayed.

webroot/rsrc/image/icon/fatcow/thumbnails/image160x120.png

This is a binary file and will not be displayed.

webroot/rsrc/image/icon/fatcow/thumbnails/image60x45.png

This is a binary file and will not be displayed.

webroot/rsrc/image/icon/fatcow/thumbnails/pdf160x120.png

This is a binary file and will not be displayed.

webroot/rsrc/image/icon/fatcow/thumbnails/pdf60x45.png

This is a binary file and will not be displayed.

webroot/rsrc/image/icon/fatcow/thumbnails/zip160x120.png

This is a binary file and will not be displayed.

webroot/rsrc/image/icon/fatcow/thumbnails/zip60x45.png

This is a binary file and will not be displayed.