@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 all "FileHasObject" edge reads and writes

Summary: Ref T13603. Removes all reads and writes to the other half of the legacy edge.

Test Plan:
- Verified I could still see file content accessible only through object attachment.
- This fixes a unit test broken by removal of only half the edge access in the previous change.

Maniphest Tasks: T13603

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

+26 -8
+26 -8
src/applications/files/query/PhabricatorFileQuery.php
··· 209 209 // If we have any files left which do need objects, load the edges now. 210 210 $object_phids = array(); 211 211 if ($need_objects) { 212 - $edge_type = PhabricatorFileHasObjectEdgeType::EDGECONST; 213 - $file_phids = mpull($need_objects, 'getPHID'); 214 - 215 - $edges = id(new PhabricatorEdgeQuery()) 216 - ->withSourcePHIDs($file_phids) 217 - ->withEdgeTypes(array($edge_type)) 218 - ->execute(); 212 + $attachments_map = $this->newAttachmentsMap($need_objects); 219 213 220 214 foreach ($need_objects as $file) { 221 - $phids = array_keys($edges[$file->getPHID()][$edge_type]); 215 + $file_phid = $file->getPHID(); 216 + $phids = $attachments_map[$file_phid]; 217 + 222 218 $file->attachObjectPHIDs($phids); 223 219 224 220 if ($is_omnipotent) { ··· 303 299 } 304 300 305 301 return $files; 302 + } 303 + 304 + private function newAttachmentsMap(array $files) { 305 + $file_phids = mpull($files, 'getPHID'); 306 + 307 + $attachments_table = new PhabricatorFileAttachment(); 308 + $attachments_conn = $attachments_table->establishConnection('r'); 309 + 310 + $attachments = queryfx_all( 311 + $attachments_conn, 312 + 'SELECT filePHID, objectPHID FROM %R WHERE filePHID IN (%Ls)', 313 + $attachments_table, 314 + $file_phids); 315 + 316 + $attachments_map = array_fill_keys($file_phids, array()); 317 + foreach ($attachments as $row) { 318 + $file_phid = $row['filePHID']; 319 + $object_phid = $row['objectPHID']; 320 + $attachments_map[$file_phid][] = $object_phid; 321 + } 322 + 323 + return $attachments_map; 306 324 } 307 325 308 326 protected function didFilterPage(array $files) {