Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15457817
D10428.id25087.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D10428.id25087.diff
View Options
diff --git a/src/applications/macro/conduit/MacroQueryConduitAPIMethod.php b/src/applications/macro/conduit/MacroQueryConduitAPIMethod.php
--- a/src/applications/macro/conduit/MacroQueryConduitAPIMethod.php
+++ b/src/applications/macro/conduit/MacroQueryConduitAPIMethod.php
@@ -30,8 +30,9 @@
}
protected function execute(ConduitAPIRequest $request) {
- $query = new PhabricatorMacroQuery();
- $query->setViewer($request->getUser());
+ $query = id(new PhabricatorMacroQuery())
+ ->setViewer($request->getUser())
+ ->needFiles(true);
$author_phids = $request->getValue('authorPHIDs');
$phids = $request->getValue('phids');
diff --git a/src/applications/macro/controller/PhabricatorMacroEditController.php b/src/applications/macro/controller/PhabricatorMacroEditController.php
--- a/src/applications/macro/controller/PhabricatorMacroEditController.php
+++ b/src/applications/macro/controller/PhabricatorMacroEditController.php
@@ -19,6 +19,7 @@
$macro = id(new PhabricatorMacroQuery())
->setViewer($user)
->withIDs(array($this->id))
+ ->needFiles(true)
->executeOne();
if (!$macro) {
return new Aphront404Response();
diff --git a/src/applications/macro/controller/PhabricatorMacroMemeController.php b/src/applications/macro/controller/PhabricatorMacroMemeController.php
--- a/src/applications/macro/controller/PhabricatorMacroMemeController.php
+++ b/src/applications/macro/controller/PhabricatorMacroMemeController.php
@@ -29,6 +29,7 @@
$macro = id(new PhabricatorMacroQuery())
->setViewer($user)
->withNames(array($macro_name))
+ ->needFiles(true)
->executeOne();
if (!$macro) {
return false;
diff --git a/src/applications/macro/controller/PhabricatorMacroViewController.php b/src/applications/macro/controller/PhabricatorMacroViewController.php
--- a/src/applications/macro/controller/PhabricatorMacroViewController.php
+++ b/src/applications/macro/controller/PhabricatorMacroViewController.php
@@ -20,6 +20,7 @@
$macro = id(new PhabricatorMacroQuery())
->setViewer($user)
->withIDs(array($this->id))
+ ->needFiles(true)
->executeOne();
if (!$macro) {
return new Aphront404Response();
diff --git a/src/applications/macro/query/PhabricatorMacroQuery.php b/src/applications/macro/query/PhabricatorMacroQuery.php
--- a/src/applications/macro/query/PhabricatorMacroQuery.php
+++ b/src/applications/macro/query/PhabricatorMacroQuery.php
@@ -12,6 +12,8 @@
private $dateCreatedBefore;
private $flagColor;
+ private $needFiles;
+
private $status = 'status-any';
const STATUS_ANY = 'status-any';
const STATUS_ACTIVE = 'status-active';
@@ -83,6 +85,11 @@
return $this;
}
+ public function needFiles($need_files) {
+ $this->needFiles = $need_files;
+ return $this;
+ }
+
protected function loadPage() {
$macro_table = new PhabricatorFileImageMacro();
$conn = $macro_table->establishConnection('r');
@@ -196,21 +203,23 @@
}
protected function didFilterPage(array $macros) {
- $file_phids = mpull($macros, 'getFilePHID');
- $files = id(new PhabricatorFileQuery())
- ->setViewer($this->getViewer())
- ->setParentQuery($this)
- ->withPHIDs($file_phids)
- ->execute();
- $files = mpull($files, null, 'getPHID');
-
- foreach ($macros as $key => $macro) {
- $file = idx($files, $macro->getFilePHID());
- if (!$file) {
- unset($macros[$key]);
- continue;
+ if ($this->needFiles) {
+ $file_phids = mpull($macros, 'getFilePHID');
+ $files = id(new PhabricatorFileQuery())
+ ->setViewer($this->getViewer())
+ ->setParentQuery($this)
+ ->withPHIDs($file_phids)
+ ->execute();
+ $files = mpull($files, null, 'getPHID');
+
+ foreach ($macros as $key => $macro) {
+ $file = idx($files, $macro->getFilePHID());
+ if (!$file) {
+ unset($macros[$key]);
+ continue;
+ }
+ $macro->attachFile($file);
}
- $macro->attachFile($file);
}
return $macros;
diff --git a/src/applications/macro/query/PhabricatorMacroSearchEngine.php b/src/applications/macro/query/PhabricatorMacroSearchEngine.php
--- a/src/applications/macro/query/PhabricatorMacroSearchEngine.php
+++ b/src/applications/macro/query/PhabricatorMacroSearchEngine.php
@@ -29,6 +29,7 @@
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
$query = id(new PhabricatorMacroQuery())
+ ->needFiles(true)
->withIDs($saved->getParameter('ids', array()))
->withPHIDs($saved->getParameter('phids', array()))
->withAuthorPHIDs($saved->getParameter('authorPHIDs', array()));
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Mar 31, 7:09 PM (1 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7728291
Default Alt Text
D10428.id25087.diff (4 KB)
Attached To
Mode
D10428: Reduce the cost of loading large numbers of macros
Attached
Detach File
Event Timeline
Log In to Comment