Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15399518
D21820.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D21820.id.diff
View Options
diff --git a/src/applications/files/query/PhabricatorFileQuery.php b/src/applications/files/query/PhabricatorFileQuery.php
--- a/src/applications/files/query/PhabricatorFileQuery.php
+++ b/src/applications/files/query/PhabricatorFileQuery.php
@@ -209,16 +209,12 @@
// If we have any files left which do need objects, load the edges now.
$object_phids = array();
if ($need_objects) {
- $edge_type = PhabricatorFileHasObjectEdgeType::EDGECONST;
- $file_phids = mpull($need_objects, 'getPHID');
-
- $edges = id(new PhabricatorEdgeQuery())
- ->withSourcePHIDs($file_phids)
- ->withEdgeTypes(array($edge_type))
- ->execute();
+ $attachments_map = $this->newAttachmentsMap($need_objects);
foreach ($need_objects as $file) {
- $phids = array_keys($edges[$file->getPHID()][$edge_type]);
+ $file_phid = $file->getPHID();
+ $phids = $attachments_map[$file_phid];
+
$file->attachObjectPHIDs($phids);
if ($is_omnipotent) {
@@ -305,6 +301,28 @@
return $files;
}
+ private function newAttachmentsMap(array $files) {
+ $file_phids = mpull($files, 'getPHID');
+
+ $attachments_table = new PhabricatorFileAttachment();
+ $attachments_conn = $attachments_table->establishConnection('r');
+
+ $attachments = queryfx_all(
+ $attachments_conn,
+ 'SELECT filePHID, objectPHID FROM %R WHERE filePHID IN (%Ls)',
+ $attachments_table,
+ $file_phids);
+
+ $attachments_map = array_fill_keys($file_phids, array());
+ foreach ($attachments as $row) {
+ $file_phid = $row['filePHID'];
+ $object_phid = $row['objectPHID'];
+ $attachments_map[$file_phid][] = $object_phid;
+ }
+
+ return $attachments_map;
+ }
+
protected function didFilterPage(array $files) {
$xform_keys = $this->needTransforms;
if ($xform_keys !== null) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Mar 18, 4:58 AM (5 d, 6 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7386605
Default Alt Text
D21820.id.diff (1 KB)
Attached To
Mode
D21820: Remove all "FileHasObject" edge reads and writes
Attached
Detach File
Event Timeline
Log In to Comment