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

Route hard-coded "/favicon.ico" requests to a favicon resource

Summary:
See PHI1719. User agents making hard-coded requests to "/favicon.ico" currently 404. This is a mild source of log noise, and we can reasonably route this request.

Limitations:

- This only routes the "PlatformSite". Other sites (custom Phame blogs, third-party sites, Phurl redirectors) won't route here for now.
- This returns a "Location:" redirect to the correct resource rather than icon data directly. This produces the right icon with the right caching behavior, and returning icon data directly is difficult in the general case. However, it won't perform/cache as well as a direct response would.

Test Plan:
- Visted `/favicon.ico`.
- Before: 404.
- After: redirect to favicon.

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

+39
+2
src/__phutil_library_map__.php
··· 3371 3371 'PhabricatorFactRaw' => 'applications/fact/storage/PhabricatorFactRaw.php', 3372 3372 'PhabricatorFactUpdateIterator' => 'applications/fact/extract/PhabricatorFactUpdateIterator.php', 3373 3373 'PhabricatorFailHisecUserLogType' => 'applications/people/userlog/PhabricatorFailHisecUserLogType.php', 3374 + 'PhabricatorFaviconController' => 'applications/system/controller/PhabricatorFaviconController.php', 3374 3375 'PhabricatorFaviconRef' => 'applications/files/favicon/PhabricatorFaviconRef.php', 3375 3376 'PhabricatorFaviconRefQuery' => 'applications/files/favicon/PhabricatorFaviconRefQuery.php', 3376 3377 'PhabricatorFavoritesApplication' => 'applications/favorites/application/PhabricatorFavoritesApplication.php', ··· 9852 9853 'PhabricatorFactRaw' => 'PhabricatorFactDAO', 9853 9854 'PhabricatorFactUpdateIterator' => 'PhutilBufferedIterator', 9854 9855 'PhabricatorFailHisecUserLogType' => 'PhabricatorUserLogType', 9856 + 'PhabricatorFaviconController' => 'PhabricatorController', 9855 9857 'PhabricatorFaviconRef' => 'Phobject', 9856 9858 'PhabricatorFaviconRefQuery' => 'Phobject', 9857 9859 'PhabricatorFavoritesApplication' => 'PhabricatorApplication',
+1
src/applications/system/application/PhabricatorSystemApplication.php
··· 24 24 return array( 25 25 '/status/' => 'PhabricatorStatusController', 26 26 '/debug/' => 'PhabricatorDebugController', 27 + '/favicon.ico' => 'PhabricatorFaviconController', 27 28 '/robots.txt' => 'PhabricatorRobotsController', 28 29 '/services/' => array( 29 30 'encoding/' => 'PhabricatorSystemSelectEncodingController',
+36
src/applications/system/controller/PhabricatorFaviconController.php
··· 1 + <?php 2 + 3 + final class PhabricatorFaviconController 4 + extends PhabricatorController { 5 + 6 + public function shouldRequireLogin() { 7 + return false; 8 + } 9 + 10 + public function handleRequest(AphrontRequest $request) { 11 + // See PHI1719. Phabricator uses "<link /"> tags in the document body 12 + // to direct user agents to icons, like this: 13 + // 14 + // <link rel="icon" href="..." /> 15 + // 16 + // However, some software requests the hard-coded path "/favicon.ico" 17 + // directly. To tidy the logs, serve some reasonable response rather than 18 + // a 404. 19 + 20 + // NOTE: Right now, this only works for the "PhabricatorPlatformSite". 21 + // Other sites (like custom Phame blogs) won't currently route this 22 + // path. 23 + 24 + $ref = id(new PhabricatorFaviconRef()) 25 + ->setWidth(64) 26 + ->setHeight(64); 27 + 28 + id(new PhabricatorFaviconRefQuery()) 29 + ->withRefs(array($ref)) 30 + ->execute(); 31 + 32 + return id(new AphrontRedirectResponse()) 33 + ->setIsExternal(true) 34 + ->setURI($ref->getURI()); 35 + } 36 + }