1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 21:02:41 +01:00

Paste - fix N query problem for file URIs

Summary: grab all the files in one big fetch, rather than serially fetching
them.   follow up from D1198.

Test Plan: viewed paste and there were no errors!

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, jungejason, btrahan, epriestley

Differential Revision: 1202
This commit is contained in:
Bob Trahan 2011-12-13 18:24:48 -08:00
parent 4ef18d35ac
commit 522b16ed12
2 changed files with 14 additions and 3 deletions

View file

@ -313,10 +313,23 @@ class PhabricatorPasteListController extends PhabricatorPasteController {
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
}
$phids = mpull($pastes, 'getFilePHID');
$file_uris = array();
if ($phids) {
$files = id(new PhabricatorFile())->loadAllWhere(
'phid in (%Ls)',
$phids
);
if ($files) {
$file_uris = mpull($files, 'getBestURI', 'getPHID');
}
}
$paste_list_rows = array();
foreach ($pastes as $paste) {
$handle = $handles[$paste->getAuthorPHID()];
$file_uri = $file_uris[$paste->getFilePHID()];
$paste_list_rows[] = array(
phutil_escape_html('P'.$paste->getID()),
@ -344,8 +357,7 @@ class PhabricatorPasteListController extends PhabricatorPasteController {
phutil_render_tag(
'a',
array(
'href' => PhabricatorFileURI::getViewURIForPHID(
$paste->getFilePHID()),
'href' => $file_uri,
),
phutil_escape_html($paste->getFilePHID())),
);

View file

@ -8,7 +8,6 @@
phutil_require_module('phabricator', 'aphront/response/redirect');
phutil_require_module('phabricator', 'applications/files/storage/file');
phutil_require_module('phabricator', 'applications/files/uri');
phutil_require_module('phabricator', 'applications/paste/controller/base');
phutil_require_module('phabricator', 'applications/paste/storage/paste');
phutil_require_module('phabricator', 'applications/phid/handle/data');