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

Support ".ico" in Celerity and simplify rewite rule configuration

Summary:
See D16734.

- Add ".ico" files to the Celerity map.
- Add a formal route for "/favicon.ico".
- Remove instructions to configure `/rsrc/` and `/favicon.ico` rewrite rules.

Long ago, we served resources directly via `/rsrc/` in at least some cases. As we added more features, this stopped working more and more often (for example, Apache can never serve CSS this way, because it doesn't know how to post-process `{$variables}`).

In modern code (until this change), only `/favicon.ico` is still expected to be served this way.

Instead, serve it with an explicit route via controller (this allows different Sites to have different favicons, for example).

Remove the instructions suggesting the old rewrite rules be configured. It's OK if they're still in place -- they won't break anything, so we don't need to rush to get users to delete them.

We should keep "webroot/favicon.ico" in place for now, since it needs to be there for users with the old rewrite rule.

Test Plan:
- Ran celerity map.
- Loaded `/favicon.ico`, got resource via route.
- Used `celerity_generate_resource_uri()` to get paths to other icons, loaded them, got icons.

Reviewers: chad

Reviewed By: chad

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

+29 -8
+5
resources/celerity/map.php
··· 16 16 'differential.pkg.js' => '634399e9', 17 17 'diffusion.pkg.css' => '91c5d3a6', 18 18 'diffusion.pkg.js' => '84c8f8fd', 19 + 'favicon.ico' => '30672e08', 19 20 'maniphest.pkg.css' => '4845691a', 20 21 'maniphest.pkg.js' => '949a7498', 21 22 'rsrc/css/aphront/aphront-bars.css' => '231ac33c', ··· 285 286 'rsrc/favicons/dark/favicon-196x196.png' => '5e06ee72', 286 287 'rsrc/favicons/dark/favicon-32x32.png' => 'bdd7e16b', 287 288 'rsrc/favicons/dark/favicon-96x96.png' => '0cf55978', 289 + 'rsrc/favicons/dark/favicon.ico' => '4343aaa6', 288 290 'rsrc/favicons/dark/mstile-144x144.png' => '4dc9d42d', 289 291 'rsrc/favicons/dark/mstile-150x150.png' => '2dc61c90', 290 292 'rsrc/favicons/dark/mstile-310x150.png' => '4fe58ab2', ··· 295 297 'rsrc/favicons/favicon-196x196.png' => '95db275e', 296 298 'rsrc/favicons/favicon-32x32.png' => '5bd18b6c', 297 299 'rsrc/favicons/favicon-96x96.png' => '7242c8e9', 300 + 'rsrc/favicons/favicon.ico' => 'cdb11121', 298 301 'rsrc/favicons/mask-icon.svg' => 'e132a80f', 299 302 'rsrc/favicons/mstile-144x144.png' => '310c2ee5', 300 303 'rsrc/favicons/mstile-150x150.png' => '74bf5133', ··· 314 317 'rsrc/favicons/red/favicon-196x196.png' => '94c089a5', 315 318 'rsrc/favicons/red/favicon-32x32.png' => '5848673e', 316 319 'rsrc/favicons/red/favicon-96x96.png' => '895d54e8', 320 + 'rsrc/favicons/red/favicon.ico' => '25172b6b', 317 321 'rsrc/favicons/red/mstile-144x144.png' => '448639f5', 318 322 'rsrc/favicons/red/mstile-150x150.png' => 'c2ba45d0', 319 323 'rsrc/favicons/red/mstile-310x150.png' => 'b0e50799', ··· 332 336 'rsrc/favicons/yellow/favicon-196x196.png' => '932c7c65', 333 337 'rsrc/favicons/yellow/favicon-32x32.png' => '005c9f92', 334 338 'rsrc/favicons/yellow/favicon-96x96.png' => '3ad9bfa9', 339 + 'rsrc/favicons/yellow/favicon.ico' => '2f5b2991', 335 340 'rsrc/favicons/yellow/mstile-144x144.png' => 'fc52335c', 336 341 'rsrc/favicons/yellow/mstile-150x150.png' => '9e556f80', 337 342 'rsrc/favicons/yellow/mstile-310x150.png' => '2c915073',
+2
src/__phutil_library_map__.php
··· 3808 3808 'PhabricatorSystemDAO' => 'applications/system/storage/PhabricatorSystemDAO.php', 3809 3809 'PhabricatorSystemDestructionGarbageCollector' => 'applications/system/garbagecollector/PhabricatorSystemDestructionGarbageCollector.php', 3810 3810 'PhabricatorSystemDestructionLog' => 'applications/system/storage/PhabricatorSystemDestructionLog.php', 3811 + 'PhabricatorSystemFaviconController' => 'applications/system/controller/PhabricatorSystemFaviconController.php', 3811 3812 'PhabricatorSystemReadOnlyController' => 'applications/system/controller/PhabricatorSystemReadOnlyController.php', 3812 3813 'PhabricatorSystemRemoveDestroyWorkflow' => 'applications/system/management/PhabricatorSystemRemoveDestroyWorkflow.php', 3813 3814 'PhabricatorSystemRemoveLogWorkflow' => 'applications/system/management/PhabricatorSystemRemoveLogWorkflow.php', ··· 8942 8943 'PhabricatorSystemDAO' => 'PhabricatorLiskDAO', 8943 8944 'PhabricatorSystemDestructionGarbageCollector' => 'PhabricatorGarbageCollector', 8944 8945 'PhabricatorSystemDestructionLog' => 'PhabricatorSystemDAO', 8946 + 'PhabricatorSystemFaviconController' => 'PhabricatorController', 8945 8947 'PhabricatorSystemReadOnlyController' => 'PhabricatorController', 8946 8948 'PhabricatorSystemRemoveDestroyWorkflow' => 'PhabricatorSystemRemoveWorkflow', 8947 8949 'PhabricatorSystemRemoveLogWorkflow' => 'PhabricatorSystemRemoveWorkflow',
+1
src/applications/celerity/controller/CelerityResourceController.php
··· 145 145 'eot' => 'font/eot', 146 146 'ttf' => 'font/ttf', 147 147 'mp3' => 'audio/mpeg', 148 + 'ico' => 'image/x-icon', 148 149 ); 149 150 } 150 151
+1
src/applications/celerity/resources/CelerityResourcesOnDisk.php
··· 39 39 'ttf', 40 40 'eot', 41 41 'mp3', 42 + 'ico', 42 43 ); 43 44 } 44 45
+1
src/applications/system/application/PhabricatorSystemApplication.php
··· 26 26 '/readonly/' => array( 27 27 '(?P<reason>[^/]+)/' => 'PhabricatorSystemReadOnlyController', 28 28 ), 29 + '/favicon.ico' => 'PhabricatorSystemFaviconController', 29 30 ); 30 31 } 31 32
+19
src/applications/system/controller/PhabricatorSystemFaviconController.php
··· 1 + <?php 2 + 3 + final class PhabricatorSystemFaviconController extends PhabricatorController { 4 + 5 + public function shouldRequireLogin() { 6 + return false; 7 + } 8 + 9 + public function processRequest() { 10 + $webroot = dirname(phutil_get_library_root('phabricator')).'/webroot/'; 11 + $content = Filesystem::readFile($webroot.'/rsrc/favicons/favicon.ico'); 12 + 13 + return id(new AphrontFileResponse()) 14 + ->setContent($content) 15 + ->setMimeType('image/x-icon') 16 + ->setCacheDurationInSeconds(phutil_units('24 hours in seconds')) 17 + ->setCanCDN(true); 18 + } 19 + }
-8
src/docs/user/configuration/configuration_guide.diviner
··· 48 48 DocumentRoot /path/to/phabricator/webroot 49 49 50 50 RewriteEngine on 51 - RewriteRule ^/rsrc/(.*) - [L,QSA] 52 - RewriteRule ^/favicon.ico - [L,QSA] 53 51 RewriteRule ^(.*)$ /index.php?__path__=$1 [B,L,QSA] 54 52 </VirtualHost> 55 53 ··· 91 89 rewrite ^/(.*)$ /index.php?__path__=/$1 last; 92 90 } 93 91 94 - location = /favicon.ico { 95 - try_files $uri =204; 96 - } 97 - 98 92 location /index.php { 99 93 fastcgi_pass localhost:9000; 100 94 fastcgi_index index.php; ··· 130 124 $HTTP["host"] =~ "phabricator(\.example\.com)?" { 131 125 server.document-root = "/path/to/phabricator/webroot" 132 126 url.rewrite-once = ( 133 - "^(/rsrc/.*)$" => "$1", 134 - "^(/favicon.ico)$" => "$1", 135 127 # This simulates QSA ("query string append") mode in apache 136 128 "^(/[^?]*)\?(.*)" => "/index.php?__path__=$1&$2", 137 129 "^(/.*)$" => "/index.php?__path__=$1",