1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-19 13:22:42 +01:00

Fix an issue with PHID/handle management in push logs

Summary: Ref T10751. This cleans this up so it's a little more modern, and fixes a possible bad access on the log detail page.

Test Plan: Viewed push log list, viewed push log detail.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10751

Differential Revision: https://secure.phabricator.com/D15765
This commit is contained in:
epriestley 2016-04-19 20:25:21 -07:00
parent 48b015a3fa
commit b9cf9e6f0d
3 changed files with 16 additions and 25 deletions

View file

@ -50,8 +50,7 @@ final class DiffusionPushEventViewController
$updates_table = id(new DiffusionPushLogListView())
->setUser($viewer)
->setLogs($logs)
->setHandles($this->loadViewerHandles(mpull($logs, 'getPusherPHID')));
->setLogs($logs);
$update_box = id(new PHUIObjectBoxView())
->setHeaderText(pht('All Pushed Updates'))

View file

@ -3,7 +3,6 @@
final class DiffusionPushLogListView extends AphrontView {
private $logs;
private $handles;
public function setLogs(array $logs) {
assert_instances_of($logs, 'PhabricatorRepositoryPushLog');
@ -11,15 +10,20 @@ final class DiffusionPushLogListView extends AphrontView {
return $this;
}
public function setHandles(array $handles) {
$this->handles = $handles;
return $this;
}
public function render() {
$logs = $this->logs;
$viewer = $this->getUser();
$handles = $this->handles;
$viewer = $this->getViewer();
$handle_phids = array();
foreach ($logs as $log) {
$handle_phids[] = $log->getPusherPHID();
$device_phid = $log->getDevicePHID();
if ($device_phid) {
$handle_phids[] = $device_phid;
}
}
$handles = $viewer->loadHandles($handle_phids);
// Figure out which repositories are editable. We only let you see remote
// IPs if you have edit capability on a repository.
@ -62,7 +66,7 @@ final class DiffusionPushLogListView extends AphrontView {
$device_phid = $log->getDevicePHID();
if ($device_phid) {
$device = $handles[$device_phid]->renderLink();
$device = $viewer->renderHandle($device_phid);
$any_host = true;
} else {
$device = null;
@ -81,7 +85,7 @@ final class DiffusionPushLogListView extends AphrontView {
'href' => $repository->getURI(),
),
$repository->getDisplayName()),
$handles[$log->getPusherPHID()]->renderLink(),
$viewer->renderHandle($log->getPusherPHID()),
$remote_address,
$log->getPushEvent()->getRemoteProtocol(),
$device,

View file

@ -92,25 +92,13 @@ final class PhabricatorRepositoryPushLogSearchEngine
return parent::buildSavedQueryFromBuiltin($query_key);
}
protected function getRequiredHandlePHIDsForResultList(
array $logs,
PhabricatorSavedQuery $query) {
$phids = array();
$phids[] = mpull($logs, 'getPusherPHID');
$phids[] = mpull($logs, 'getDevicePHID');
$phids = array_mergev($phids);
$phids = array_filter($phids);
return $phids;
}
protected function renderResultList(
array $logs,
PhabricatorSavedQuery $query,
array $handles) {
$table = id(new DiffusionPushLogListView())
->setUser($this->requireViewer())
->setHandles($handles)
->setViewer($this->requireViewer())
->setLogs($logs);
return id(new PhabricatorApplicationSearchResultView())