mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 19:40:55 +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:
parent
4ef18d35ac
commit
522b16ed12
2 changed files with 14 additions and 3 deletions
|
@ -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())),
|
||||
);
|
||||
|
|
|
@ -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');
|
||||
|
|
Loading…
Reference in a new issue