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

Skip loading file transform sources when we know a file is not transformed

Summary:
Depends on D19223. Ref T13106. When we're loading a file, we currently test if it's a transformed version of another file (usually, a thumbnail) and apply policy behavior if it is.

We know that builtins and profile images are never transforms and that the policy behavior for these files doesn't matter anyway. Skip loading transforms for these files.

Test Plan: Saw local queries drop from 146 to 139 with no change in behavior.

Maniphest Tasks: T13106

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

+15 -8
+15 -8
src/applications/files/query/PhabricatorFileQuery.php
··· 165 165 // However, in some special cases where we know files will always be 166 166 // visible, we skip this. See T8478 and T13106. 167 167 $need_objects = array(); 168 + $need_xforms = array(); 168 169 foreach ($files as $file) { 169 170 $always_visible = false; 170 171 ··· 187 188 } 188 189 189 190 $need_objects[] = $file; 191 + $need_xforms[] = $file; 190 192 } 191 193 192 194 $viewer = $this->getViewer(); ··· 226 228 // If this file is a transform of another file, load that file too. If you 227 229 // can see the original file, you can see the thumbnail. 228 230 229 - // TODO: It might be nice to put this directly on PhabricatorFile and remove 230 - // the PhabricatorTransformedFile table, which would be a little simpler. 231 + // TODO: It might be nice to put this directly on PhabricatorFile and 232 + // remove the PhabricatorTransformedFile table, which would be a little 233 + // simpler. 231 234 232 - $xforms = id(new PhabricatorTransformedFile())->loadAllWhere( 233 - 'transformedPHID IN (%Ls)', 234 - mpull($files, 'getPHID')); 235 - $xform_phids = mpull($xforms, 'getOriginalPHID', 'getTransformedPHID'); 236 - foreach ($xform_phids as $derived_phid => $original_phid) { 237 - $object_phids[$original_phid] = true; 235 + if ($need_xforms) { 236 + $xforms = id(new PhabricatorTransformedFile())->loadAllWhere( 237 + 'transformedPHID IN (%Ls)', 238 + mpull($need_xforms, 'getPHID')); 239 + $xform_phids = mpull($xforms, 'getOriginalPHID', 'getTransformedPHID'); 240 + foreach ($xform_phids as $derived_phid => $original_phid) { 241 + $object_phids[$original_phid] = true; 242 + } 243 + } else { 244 + $xform_phids = array(); 238 245 } 239 246 240 247 $object_phids = array_keys($object_phids);