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:
parent
48b015a3fa
commit
b9cf9e6f0d
3 changed files with 16 additions and 25 deletions
|
@ -50,8 +50,7 @@ final class DiffusionPushEventViewController
|
||||||
|
|
||||||
$updates_table = id(new DiffusionPushLogListView())
|
$updates_table = id(new DiffusionPushLogListView())
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
->setLogs($logs)
|
->setLogs($logs);
|
||||||
->setHandles($this->loadViewerHandles(mpull($logs, 'getPusherPHID')));
|
|
||||||
|
|
||||||
$update_box = id(new PHUIObjectBoxView())
|
$update_box = id(new PHUIObjectBoxView())
|
||||||
->setHeaderText(pht('All Pushed Updates'))
|
->setHeaderText(pht('All Pushed Updates'))
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
final class DiffusionPushLogListView extends AphrontView {
|
final class DiffusionPushLogListView extends AphrontView {
|
||||||
|
|
||||||
private $logs;
|
private $logs;
|
||||||
private $handles;
|
|
||||||
|
|
||||||
public function setLogs(array $logs) {
|
public function setLogs(array $logs) {
|
||||||
assert_instances_of($logs, 'PhabricatorRepositoryPushLog');
|
assert_instances_of($logs, 'PhabricatorRepositoryPushLog');
|
||||||
|
@ -11,15 +10,20 @@ final class DiffusionPushLogListView extends AphrontView {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setHandles(array $handles) {
|
|
||||||
$this->handles = $handles;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
$logs = $this->logs;
|
$logs = $this->logs;
|
||||||
$viewer = $this->getUser();
|
$viewer = $this->getViewer();
|
||||||
$handles = $this->handles;
|
|
||||||
|
$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
|
// Figure out which repositories are editable. We only let you see remote
|
||||||
// IPs if you have edit capability on a repository.
|
// IPs if you have edit capability on a repository.
|
||||||
|
@ -62,7 +66,7 @@ final class DiffusionPushLogListView extends AphrontView {
|
||||||
|
|
||||||
$device_phid = $log->getDevicePHID();
|
$device_phid = $log->getDevicePHID();
|
||||||
if ($device_phid) {
|
if ($device_phid) {
|
||||||
$device = $handles[$device_phid]->renderLink();
|
$device = $viewer->renderHandle($device_phid);
|
||||||
$any_host = true;
|
$any_host = true;
|
||||||
} else {
|
} else {
|
||||||
$device = null;
|
$device = null;
|
||||||
|
@ -81,7 +85,7 @@ final class DiffusionPushLogListView extends AphrontView {
|
||||||
'href' => $repository->getURI(),
|
'href' => $repository->getURI(),
|
||||||
),
|
),
|
||||||
$repository->getDisplayName()),
|
$repository->getDisplayName()),
|
||||||
$handles[$log->getPusherPHID()]->renderLink(),
|
$viewer->renderHandle($log->getPusherPHID()),
|
||||||
$remote_address,
|
$remote_address,
|
||||||
$log->getPushEvent()->getRemoteProtocol(),
|
$log->getPushEvent()->getRemoteProtocol(),
|
||||||
$device,
|
$device,
|
||||||
|
|
|
@ -92,25 +92,13 @@ final class PhabricatorRepositoryPushLogSearchEngine
|
||||||
return parent::buildSavedQueryFromBuiltin($query_key);
|
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(
|
protected function renderResultList(
|
||||||
array $logs,
|
array $logs,
|
||||||
PhabricatorSavedQuery $query,
|
PhabricatorSavedQuery $query,
|
||||||
array $handles) {
|
array $handles) {
|
||||||
|
|
||||||
$table = id(new DiffusionPushLogListView())
|
$table = id(new DiffusionPushLogListView())
|
||||||
->setUser($this->requireViewer())
|
->setViewer($this->requireViewer())
|
||||||
->setHandles($handles)
|
|
||||||
->setLogs($logs);
|
->setLogs($logs);
|
||||||
|
|
||||||
return id(new PhabricatorApplicationSearchResultView())
|
return id(new PhabricatorApplicationSearchResultView())
|
||||||
|
|
Loading…
Reference in a new issue