Differential D8286 Diff 19727 src/applications/transactions/query/PhabricatorApplicationTransactionQuery.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/query/PhabricatorApplicationTransactionQuery.php
| Show First 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | if ($this->needComments) { | ||||
| } | } | ||||
| } | } | ||||
| } else { | } else { | ||||
| foreach ($xactions as $xaction) { | foreach ($xactions as $xaction) { | ||||
| $xaction->setCommentNotLoaded(true); | $xaction->setCommentNotLoaded(true); | ||||
| } | } | ||||
| } | } | ||||
| if ($this->needHandles) { | |||||
| $phids = array(); | |||||
| foreach ($xactions as $xaction) { | |||||
| $phids[$xaction->getPHID()] = $xaction->getRequiredHandlePHIDs(); | |||||
| } | |||||
| $handles = array(); | |||||
| $merged = array_mergev($phids); | |||||
| if ($merged) { | |||||
| $handles = id(new PhabricatorHandleQuery()) | |||||
| ->setViewer($this->getViewer()) | |||||
| ->withPHIDs($merged) | |||||
| ->execute(); | |||||
| } | |||||
| foreach ($xactions as $xaction) { | |||||
| $xaction->setHandles( | |||||
| array_select_keys( | |||||
| $handles, | |||||
| $phids[$xaction->getPHID()])); | |||||
| } | |||||
| } | |||||
| return $xactions; | return $xactions; | ||||
| } | } | ||||
| protected function willFilterPage(array $xactions) { | protected function willFilterPage(array $xactions) { | ||||
| $object_phids = array_keys(mpull($xactions, null, 'getObjectPHID')); | $object_phids = array_keys(mpull($xactions, null, 'getObjectPHID')); | ||||
| $objects = id(new PhabricatorObjectQuery()) | $objects = id(new PhabricatorObjectQuery()) | ||||
| ->setViewer($this->getViewer()) | ->setViewer($this->getViewer()) | ||||
| ->setParentQuery($this) | ->setParentQuery($this) | ||||
| ->withPHIDs($object_phids) | ->withPHIDs($object_phids) | ||||
| ->execute(); | ->execute(); | ||||
| foreach ($xactions as $key => $xaction) { | foreach ($xactions as $key => $xaction) { | ||||
| $object_phid = $xaction->getObjectPHID(); | $object_phid = $xaction->getObjectPHID(); | ||||
| if (empty($objects[$object_phid])) { | if (empty($objects[$object_phid])) { | ||||
| unset($xactions[$key]); | unset($xactions[$key]); | ||||
| continue; | continue; | ||||
| } | } | ||||
| $xaction->attachObject($objects[$object_phid]); | $xaction->attachObject($objects[$object_phid]); | ||||
| } | } | ||||
| // NOTE: We have to do this after loading objects, because the objects | |||||
| // may help determine which handles are required (for example, in the case | |||||
| // of custom fields. | |||||
| if ($this->needHandles) { | |||||
| $phids = array(); | |||||
| foreach ($xactions as $xaction) { | |||||
| $phids[$xaction->getPHID()] = $xaction->getRequiredHandlePHIDs(); | |||||
| } | |||||
| $handles = array(); | |||||
| $merged = array_mergev($phids); | |||||
| if ($merged) { | |||||
| $handles = id(new PhabricatorHandleQuery()) | |||||
| ->setViewer($this->getViewer()) | |||||
| ->withPHIDs($merged) | |||||
| ->execute(); | |||||
| } | |||||
| foreach ($xactions as $xaction) { | |||||
| $xaction->setHandles( | |||||
| array_select_keys( | |||||
| $handles, | |||||
| $phids[$xaction->getPHID()])); | |||||
| } | |||||
| } | |||||
| return $xactions; | return $xactions; | ||||
| } | } | ||||
| private function buildWhereClause(AphrontDatabaseConnection $conn_r) { | private function buildWhereClause(AphrontDatabaseConnection $conn_r) { | ||||
| $where = array(); | $where = array(); | ||||
| if ($this->phids) { | if ($this->phids) { | ||||
| $where[] = qsprintf( | $where[] = qsprintf( | ||||
| ▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines | |||||