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

Diffusion file view: Restrict blame and coverage to logged-in users only

Summary:
It's 2025 and LLM scrapers hit every website, creating performance issues.
Thus restrict the vast majority of links exposed in Diffusion's single file view to logged-in users only.

The next escalation step would be making Diffusion available to logged-in users only which is a worse user experience (links in tasks to revisions not linked anymore etc).

Patch originally crafted by @aklapper.

Closes T16138

Test Plan: Go to a single file of a repository hosted in Diffusion logged out and logged in.

Reviewers: O1 Blessed Committers, aklapper

Reviewed By: O1 Blessed Committers, aklapper

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T16138

Differential Revision: https://we.phorge.it/D26141

+19 -4
+4
src/applications/files/document/PhabricatorDocumentEngine.php
··· 80 80 return false; 81 81 } 82 82 83 + /** 84 + * Check if the engine supports the blame feature. 85 + * @return bool 86 + */ 83 87 public function canBlame(PhabricatorDocumentRef $ref) { 84 88 return false; 85 89 }
+7 -2
src/applications/files/document/PhabricatorSourceDocumentEngine.php
··· 14 14 } 15 15 16 16 public function canBlame(PhabricatorDocumentRef $ref) { 17 - return true; 17 + // Since 2025, the features 'blame' and 'coverage' require login, 18 + // due to aggressive LLM/AI web scrapers following all these links, 19 + // decreasing server performance. 20 + // Scrapers are invited to pull code repos via a command line checkout. 21 + return $this->getViewer()->isLoggedIn(); 18 22 } 19 23 20 24 protected function getDocumentIconIcon(PhabricatorDocumentRef $ref) { ··· 50 54 } 51 55 52 56 $options = array(); 53 - if ($ref->getBlameURI() && $this->getBlameEnabled()) { 57 + if ($ref->getBlameURI() && $this->getBlameEnabled() 58 + && $this->canBlame($ref)) { 54 59 $content = phutil_split_lines($content); 55 60 $blame = range(1, count($content)); 56 61 $blame = array_fuse($blame);
+8 -2
src/applications/files/document/render/PhabricatorDocumentRenderingEngine.php
··· 69 69 $engine->setHighlightingConfiguration($highlight_setting); 70 70 } 71 71 72 - $blame_setting = ($request->getStr('blame') !== 'off'); 72 + $blame_setting = false; 73 + if ($engine->canBlame($ref)) { 74 + $blame_setting = ($request->getStr('blame') !== 'off'); 75 + } 73 76 $engine->setBlameConfiguration($blame_setting); 74 77 75 78 $views = array(); ··· 217 220 $engine->setHighlightingConfiguration($highlight_setting); 218 221 } 219 222 220 - $blame_setting = ($request->getStr('blame') !== 'off'); 223 + $blame_setting = false; 224 + if ($engine->canBlame($ref)) { 225 + $blame_setting = ($request->getStr('blame') !== 'off'); 226 + } 221 227 $engine->setBlameConfiguration($blame_setting); 222 228 223 229 try {